This commit is contained in:
Ines Montani 2020-06-22 00:45:40 +02:00
parent 1e5b4d8524
commit 79dd824906
3 changed files with 42 additions and 30 deletions

View File

@ -1,7 +1,4 @@
from spacy.cli import app
from typer.main import get_command
if __name__ == "__main__":
command = get_command(app)
# Ensure that the help messages always display the correct prompt
command(prog_name="python -m spacy")
from spacy.cli import setup_cli
setup_cli()

View File

@ -1,13 +1,28 @@
from ._app import app # noqa: F401
from wasabi import msg
from ._app import app, setup_cli # noqa: F401
# These are the actual functions, NOT the wrapped CLI commands. The CLI commands
# are registered automatically and won't have to be imported here.
from .download import download # noqa: F401
from .info import info # noqa: F401
from .package import package # noqa: F401
from .profile import profile # noqa: F401
from .train_from_config import train_cli # noqa: F401
from .train_from_config import train # noqa: F401
from .pretrain import pretrain # noqa: F401
from .debug_data import debug_data # noqa: F401
from .evaluate import evaluate # noqa: F401
from .convert import convert # noqa: F401
from .init_model import init_model # noqa: F401
from .validate import validate # noqa: F401
from .project import project_cli # noqa: F401
from .project import project_clone, project_get_assets, project_run # noqa: F401
@app.command("link", no_args_is_help=True, deprecated=True, hidden=True)
def link(*args, **kwargs):
"""As of spaCy v3.0, model symlinks are deprecated. You can load models
using their full names or from a directory path."""
msg.warn(
"As of spaCy v3.0, model symlinks are deprecated. You can load models "
"using their full names or from a directory path."
)

View File

@ -1,31 +1,31 @@
from typing import Optional
import typer
from wasabi import msg
from typer.main import get_command
def Arg(*args, help=None, **kwargs):
COMMAND = "python -m spacy"
NAME = "spacy"
HELP = """spaCy Command-line Interface
DOCS: https://spacy.io/api/cli
"""
app = typer.Typer(name=NAME, help=HELP)
def Arg(*args, help: Optional[str] = None, **kwargs) -> typer.Argument:
"""Wrapper for Typer's annotation to keep it short and set defaults."""
# Filter out help for now until it's officially supported
return typer.Argument(*args, **kwargs)
def Opt(*args, **kwargs):
def Opt(*args, **kwargs) -> typer.Option:
"""Wrapper for Typer's annotation to keep it short and set defaults."""
return typer.Option(*args, show_default=True, **kwargs)
app = typer.Typer(
name="spacy",
help="""spaCy Command-line Interface
DOCS: https://spacy.io/api/cli
""",
)
@app.command("link", no_args_is_help=True, deprecated=True, hidden=True)
def link(*args, **kwargs):
"""As of spaCy v3.0, model symlinks are deprecated. You can load models
using their full names or from a directory path."""
msg.warn(
"As of spaCy v3.0, model symlinks are deprecated. You can load models "
"using their full names or from a directory path."
)
def setup_cli() -> None:
# Ensure that the help messages always display the correct prompt
command = get_command(app)
command(prog_name=COMMAND)