diff --git a/spacy/cli/info.py b/spacy/cli/info.py index dbacf66fc..2c97eb340 100644 --- a/spacy/cli/info.py +++ b/spacy/cli/info.py @@ -13,8 +13,9 @@ from .. import about @plac.annotations( model=("optional: shortcut link of model", "positional", None, str), - markdown=("generate Markdown for GitHub issues", "flag", "md", str)) -def info(model=None, markdown=False): + markdown=("generate Markdown for GitHub issues", "flag", "md", str), + silent=("don't print anything (just return)", "flag", "s")) +def info(model=None, markdown=False, silent=False): """Print info about spaCy installation. If a model shortcut link is speficied as an argument, print model information. Flag --markdown prints details in Markdown for easy copy-pasting to GitHub issues. @@ -33,14 +34,17 @@ def info(model=None, markdown=False): meta['source'] = path2str(model_path.resolve()) else: meta['source'] = path2str(model_path) - print_info(meta, 'model %s' % model, markdown) - else: - data = {'spaCy version': about.__version__, - 'Location': path2str(Path(__file__).parent.parent), - 'Platform': platform.platform(), - 'Python version': platform.python_version(), - 'Models': list_models()} + if not silent: + print_info(meta, 'model %s' % model, markdown) + return meta + data = {'spaCy version': about.__version__, + 'Location': path2str(Path(__file__).parent.parent), + 'Platform': platform.platform(), + 'Python version': platform.python_version(), + 'Models': list_models()} + if not silent: print_info(data, 'spaCy', markdown) + return data def print_info(data, title, markdown):