Ejemplo n.º 1
0
def test_basic_functionality_with_commandcollection(runner):
    @click.group()
    def cli1():
        pass

    @cli1.command()
    def foo():
        pass

    @cli1.command()
    def bar():
        pass

    @click.group()
    def cli2():
        pass

    @cli2.command()
    def barrr():
        pass

    cli = DYMCommandCollection(sources=[cli1, cli2])
    result = runner.invoke(cli, ["barr"])
    assert result.output == ("Usage: root [OPTIONS] COMMAND [ARGS]...\n\n"
                             "Error: No such command \"barr\".\n\n"
                             "Did you mean one of these?\n"
                             "    barrr\n"
                             "    bar\n")
Ejemplo n.º 2
0
        sequential=state.installstate.sequential,
        pypi_mirror=state.pypi_mirror,
    )
    if retcode:
        ctx.abort()


@cli.command(
    short_help="Uninstalls all packages not specified in Pipfile.lock.")
@option("--bare", is_flag=True, default=False, help="Minimal output.")
@option("--dry-run",
        is_flag=True,
        default=False,
        help="Just output unneeded packages.")
@verbose_option
@three_option
@python_option
@pass_state
@pass_context
def clean(ctx, state, dry_run=False, bare=False, user=False):
    """Uninstalls all packages not specified in Pipfile.lock."""
    from ..core import do_clean
    do_clean(ctx=ctx, three=state.three, python=state.python, dry_run=dry_run)


# Only invoke the "did you mean" when an argument wasn't passed (it breaks those).
if "-" not in "".join(sys.argv) and len(sys.argv) > 1:
    cli = DYMCommandCollection(sources=[cli])
if __name__ == "__main__":
    cli()