Skip to content

Subcommands prefixed with a forward slash are seemingly ignored #1322

@mattrobenolt

Description

@mattrobenolt

I don't actually have any clue what's going on here, but I've tracked the misbehavior down to a specific commit, with a failing test fails on this commit, but succeeds on the previous commit.

Let's start with the test case:

def test_bad_command(runner):
    @click.group()
    def cli():
        pass

    @cli.command()
    def wups():
        pass

    result = runner.invoke(cli, ['other'])
    assert 'No such command' in result.output

    result = runner.invoke(cli, ['/other'])
    assert 'No such command' in result.output

This probably explains the issue better. In normal situations, we'd expect some call to cli other to come back and error with "No such command ...", but in the case if prefixing with a forward slash, it somehow tricks the parser into ignoring the entire argument and instead, we get the help of the parent command.

This behavior seems to be broken starting with commit 0a2919f, and the tests fail when applied here, but pass when applied against e68766c.

Let me know if there's more information I can provide to help find the issue.

To add to it, in terms of releases, this means the behavior worked against Click 5.1, but has failed since Click 6.0 and continues to not work through latest master.

Metadata

Metadata

Assignees

No one assigned

    Labels

    f:chainfeature: chained commands

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions