New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generated help with aliased group shows abbreviated command in usage #1422
Comments
I believe line 1280 in core.py should be:
instead of:
|
In an attempt to reproduce this issue, I have tried the following example: # main.py
class AliasedGroup(click.Group):
def get_command(self, ctx, cmd_name):
rv = click.Group.get_command(self, ctx, cmd_name)
if rv is not None:
return rv
matches = [x for x in self.list_commands(ctx)
if x.startswith(cmd_name)]
if not matches:
return None
elif len(matches) == 1:
return click.Group.get_command(self, ctx, matches[0])
ctx.fail('Too many matches: %s' % ', '.join(sorted(matches)))
@click.command(cls=AliasedGroup)
def cli():
pass
@cli.command()
def push():
click.echo('this is push')
@cli.command()
def pop():
click.echo('this is pop')
if __name__ == '__main__':
cli() $ python main.py pu --help
Usage: main.py push [OPTIONS]
Options:
--help Show this message and exit. Based on the above input/output, I am getting the full name of the |
After triple checking, the example does reproduce the issue, there was some confusion over a few things being worked on at the same time. |
The typical AliasGroup class overrides the get_command method and returns a matching sub command; however, when help is displayed, the usage information shows the matched abbreviated subcommand instead of the full subcommand name. After debugging, I found that the context.info_name contains the the abbreviated sub command name. I think when a sub-command context is being created, it should use the full command name for this field rather than what the user typed.
The text was updated successfully, but these errors were encountered: