2020-06-21 14:44:00 +03:00
|
|
|
import typer
|
2020-06-22 01:45:40 +03:00
|
|
|
from typer.main import get_command
|
2020-06-21 14:44:00 +03:00
|
|
|
|
|
|
|
|
2020-06-22 01:45:40 +03:00
|
|
|
COMMAND = "python -m spacy"
|
|
|
|
NAME = "spacy"
|
|
|
|
HELP = """spaCy Command-line Interface
|
|
|
|
|
|
|
|
DOCS: https://spacy.io/api/cli
|
|
|
|
"""
|
2020-07-09 02:42:51 +03:00
|
|
|
PROJECT_HELP = f"""Command-line interface for spaCy projects and working with
|
|
|
|
project templates. You'd typically start by cloning a project template to a local
|
|
|
|
directory and fetching its assets like datasets etc. See the project's
|
|
|
|
project.yml for the available commands.
|
|
|
|
"""
|
2020-06-22 01:45:40 +03:00
|
|
|
|
|
|
|
|
|
|
|
app = typer.Typer(name=NAME, help=HELP)
|
2020-07-09 02:42:51 +03:00
|
|
|
project_cli = typer.Typer(name="project", help=PROJECT_HELP, no_args_is_help=True)
|
|
|
|
app.add_typer(project_cli)
|
2020-06-22 01:45:40 +03:00
|
|
|
|
2020-06-25 13:27:19 +03:00
|
|
|
# Wrappers for Typer's annotations. Initially created to set defaults and to
|
|
|
|
# keep the names short, but not needed at the moment.
|
|
|
|
Arg = typer.Argument
|
|
|
|
Opt = typer.Option
|
2020-06-21 14:44:00 +03:00
|
|
|
|
|
|
|
|
2020-06-22 01:45:40 +03:00
|
|
|
def setup_cli() -> None:
|
|
|
|
# Ensure that the help messages always display the correct prompt
|
|
|
|
command = get_command(app)
|
|
|
|
command(prog_name=COMMAND)
|