Context.params isn't setup in the MultiCommand.list_commands method
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.7k
- Forks
- 2.3k
- Avg merge
- 1d 30m
- Merged PRs (30d)
- 18
Description
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.
https://github.com/pallets/click/blob/fef921a4d0c807673d7800af4dd4ca604f6489e4/src/click/core.py#L1242
https://github.com/pallets/click/blob/fef921a4d0c807673d7800af4dd4ca604f6489e4/src/click/core.py#L1217
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported behavior with python -m bkm -f AAA --help, then inspect src/click/core.py around MultiCommand.list_commands, get_command, and parse_args, along with the referenced bkm.py. Determine whether parsed options should be available during command listing, and consider the issue complete when the documented behavior is resolved and verified against this reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100