Add --branch to project clone

This commit is contained in:
Ines Montani 2020-09-10 11:08:15 +02:00
parent b7afd09d27
commit 15bc3a37b4
2 changed files with 13 additions and 9 deletions

View File

@ -16,6 +16,7 @@ def project_clone_cli(
name: str = Arg(..., help="The name of the template to clone"), name: str = Arg(..., help="The name of the template to clone"),
dest: Optional[Path] = Arg(None, help="Where to clone the project. Defaults to current working directory", exists=False), dest: Optional[Path] = Arg(None, help="Where to clone the project. Defaults to current working directory", exists=False),
repo: str = Opt(about.__projects__, "--repo", "-r", help="The repository to clone from"), repo: str = Opt(about.__projects__, "--repo", "-r", help="The repository to clone from"),
branch: str = Opt("master", "--branch", "-b", help="The branch to clone from")
# fmt: on # fmt: on
): ):
"""Clone a project template from a repository. Calls into "git" and will """Clone a project template from a repository. Calls into "git" and will
@ -30,7 +31,9 @@ def project_clone_cli(
project_clone(name, dest, repo=repo) project_clone(name, dest, repo=repo)
def project_clone(name: str, dest: Path, *, repo: str = about.__projects__) -> None: def project_clone(
name: str, dest: Path, *, repo: str = about.__projects__, branch: str = "master"
) -> None:
"""Clone a project template from a repository. """Clone a project template from a repository.
name (str): Name of subdirectory to clone. name (str): Name of subdirectory to clone.

View File

@ -893,7 +893,7 @@ can provide any other repo (public or private) that you have access to using the
<!-- TODO: update example once we've decided on repo structure --> <!-- TODO: update example once we've decided on repo structure -->
```cli ```cli
$ python -m spacy project clone [name] [dest] [--repo] $ python -m spacy project clone [name] [dest] [--repo] [--branch]
``` ```
> #### Example > #### Example
@ -909,10 +909,11 @@ $ python -m spacy project clone [name] [dest] [--repo]
> ``` > ```
| Name | Description | | Name | Description |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | The name of the template to clone, relative to the repo. Can be a top-level directory or a subdirectory like `dir/template`. ~~str (positional)~~ | | `name` | The name of the template to clone, relative to the repo. Can be a top-level directory or a subdirectory like `dir/template`. ~~str (positional)~~ |
| `dest` | Where to clone the project. Defaults to current working directory. ~~Path (positional)~~ | | `dest` | Where to clone the project. Defaults to current working directory. ~~Path (positional)~~ |
| `--repo`, `-r` | The repository to clone from. Can be any public or private Git repo you have access to. ~~str (option)~~ | | `--repo`, `-r` | The repository to clone from. Can be any public or private Git repo you have access to. ~~str (option)~~ |
| `--branch`, `-b` | The branch to clone from. Defaults to `master`. ~~str (option)~~ |
| `--help`, `-h` | Show help message and available arguments. ~~bool (flag)~~ | | `--help`, `-h` | Show help message and available arguments. ~~bool (flag)~~ |
| **CREATES** | The cloned [project directory](/usage/projects#project-files). | | **CREATES** | The cloned [project directory](/usage/projects#project-files). |