Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Context.params isn't setup in the MultiCommand.list_commands method #1574

@polikeiji

Description

@polikeiji

Expected Behavior

I can refer parsed options in MultiCommand.list_commands method.

Actual Behavior

I can't. Options aren't initialized in the list_commands.

I'm creating a CLI tool that dynamically loads subcommands from a file. And the location of the file is specified by an option of the CLI tool. I can refer the parsed option in MultiCommand.get_command but I can't refer it in MultiCommand.list_commands method.

I think the list_command method is called before finishing the parse_args method so we can't use parsed options in the list_commands.

echo(ctx.get_help(), color=ctx.color)

for subcommand in self.list_commands(ctx):

I created the following file and I got an empty dictionary object by the logger.debug when I execute the following command.

https://github.com/polikeiji/bkm/blob/master/bkm.py#L94

python -m bkm -f AAA --help

Is this behavior the expected one?

Environment

  • Python version: 3.8.0
  • Click version: 7.1.2

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