tyrannosaurus.cli

Command-line interface.

Original source: https://github.com/dmyersturnbull/tyrannosaurus Copyright 2020–2021 Douglas Myers-Turnbull Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0

Module Contents

tyrannosaurus.cli.cli
tyrannosaurus.cli.logger
class tyrannosaurus.cli.CliCommands

Commands for Tyrannosaurus.

_APACHE2
_ENV_YAML
static build(bare: bool = flag('bare', "Don't use tox or virtualenv."), dry_run: bool = flag('dry-run', "Don't run; just output. Useful for making a script template."), verbose: bool = flag('verbose', 'Output more info')) None

Syncs, builds, and tests your project.

If bare is NOT set, runs:
  • tyrannosaurus sync

  • poetry lock

  • tox

  • tyrannosaurus clean

If the bare IS set: Runs the commands without tox and without creating a new virtualenv. This can be useful if you’re using Conda and have a dependency only available through Anaconda. It’s also often faster. This command is for convenience and isn’t very customizable. In this case, runs:

  • tyrannosaurus sync

  • poetry lock

  • pre-commit run check-toml

  • pre-commit run check-yaml

  • pre-commit run check-json

  • poetry check

  • poetry build

  • poetry install -v

  • poetry run pytest –cov

  • poetry run flake8 tyrannosaurus

  • poetry run flake8 docs

  • poetry run flake8 –ignore=D100,D101,D102,D103,D104,S101 tests

  • sphinx-build -b html docs docs/html

  • tyrannosaurus clean

  • pip install .

static build_internal(bare: bool = False, dry: bool = False) Sequence[str]
static clean(dists: bool = flag('dists', 'Remove dists'), aggressive: bool = flag('aggressive', 'Delete additional files, including .swp and .ipython_checkpoints'), hard_delete: bool = flag('hard-delete', 'Use shutil.rmtree instead of moving to .tyrannosaurus'), dry_run: bool = flag('dry-run', "Don't write; just output"), verbose: bool = flag('verbose', 'Output more information')) None

Remove unwanted files. Deletes the contents of .tyrannosaurus. Then trashes temporary and unwanted files and directories to a tree under .tyrannosaurus.

classmethod commands()
static env(path: pathlib.Path = typer.Option(_ENV_YAML, help='Write to this path'), name: Optional[str] = typer.Option(None, help='Name of the environment. [default: project name]', show_default=False), dev: bool = flag('dev', 'Include dev/build dependencies'), extras: bool = flag('extras', 'Include optional dependencies'), dry_run: bool = flag('dry-run', "Don't write; just output"), verbose: bool = flag('verbose', 'Output more info')) None

Generate an Anaconda environment file.

static info() None

Print Tyrannosaurus info.

static new(name: str = typer.Argument('project', help='The name of the project, including any dashes or capital letters'), license: str = typer.Option('apache2', help=f"License name. One of {', '.join((s.name for s in License))}"), user: Optional[str] = typer.Option(None, help='GitHub user or org'), authors: Optional[str] = typer.Option(None, help='Author names, comma-separated'), desc: str = typer.Option('A Python project', help='Short project description'), keywords: str = typer.Option('', help='List of <6 keywords, comma-separated', show_default=False), version: str = typer.Option('0.1.0', help="Your project's semantic version"), status: Optional[str] = typer.Option(None, help=inspect.cleandoc(f"\n                PyPi classifier for dev status.\n                One of: {', '.join(DevStatus)}\n                [default: chosen by 'version']\n                "), show_choices=False), track: bool = flag('track', 'Track an empty remote repo'), extras: bool = flag('extras', 'Include uncommon files like codemeta.json'), tyranno: str = typer.Option('current', help=inspect.cleandoc("\n                Tyrannosaurus version to use as the template.\n                Choices: an exact version, 'current' (this version), 'stable', or 'latest'.\n                ")), prompt: bool = flag('prompt', 'Prompt for info'), verbose: bool = flag('verbose', 'Output more info')) None

Create a new project.

static recipe(dry_run: bool = flag('dry-run', "Don't write; just output"), verbose: bool = flag('verbose', 'Output more info')) None

Generate a Conda recipe using grayskull.

static sync(dry_run: bool = flag('dry-run', "Don't write; just output"), verbose: bool = flag('verbose', 'Output more info')) None

Sync project metadata between configured files.

static update(auto_fix=flag('auto-fix', 'Update dependencies in place (not supported yet)', hidden=True), verbose: bool = flag('verbose', 'Output more information')) None

Find and list dependencies that could be updated.

Parameters
  • auto_fix – Update dependencies in place (not supported yet)

  • verbose – Output more information

class tyrannosaurus.cli.CliState
dry_run :bool = False
verbose :bool = False
__post_init__()
class tyrannosaurus.cli.Msg
classmethod failure(msg: str) None
classmethod info(msg: str) None
classmethod success(msg: str) None
classmethod write_info()
class tyrannosaurus.cli._DevNull

Pretends to write but doesn’t.

__enter__()
__exit__(exc_type, exc_value, traceback)
close()
flush()
write(msg)
tyrannosaurus.cli._fix_docstrings(commands)
tyrannosaurus.cli.flag(name: str, desc: str, **kwargs) typer.Option
tyrannosaurus.cli.tyranno_main(version: bool = flag('version', 'Write version and exit'), info: bool = flag('info', "Write info and exit (same as 'tyrannosaurus info')"))

Tyrannosaurus. Tyrannosaurus can create new modern Python projects from a template and synchronize metadata across the project.