The call stack is displayed when an exception is returned when an invalid parameter is displayed during command line association.
Open
Nobody has claimed this yet.
parsing
- Dominant language
- Python
- Stars
- 17.7k
- Forks
- 2.3k
- Avg merge
- 1d 30m
- Merged PRs (30d)
- 18
Description
def resolve_command(
self, ctx: Context, args: list[str]
) -> tuple[str | None, Command | None, list[str]]:
cmd_name = make_str(args[0])
original_cmd_name = cmd_name
# Get the command
cmd = self.get_command(ctx, cmd_name)
when get_command return ctx.fail,the call stack is displayed
Traceback (most recent call last):
File "/usr/local/bin/config", line 8, in <module>
sys.exit(config())
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 777, in main
_bashcomplete(self, prog_name, complete_var)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 72, in _bashcomplete
if bashcomplete(cmd, prog_name, complete_var, complete_instr):
File "/usr/local/lib/python3.9/site-packages/click/_bashcomplete.py", line 373, in bashcomplete
return do_complete(cli, prog_name, shell == "zsh")
File "/usr/local/lib/python3.9/site-packages/click/_bashcomplete.py", line 334, in do_complete
for item in get_choices(cli, prog_name, args, incomplete):
File "/usr/local/lib/python3.9/site-packages/click/_bashcomplete.py", line 282, in get_choices
ctx = resolve_ctx(cli, prog_name, args)
File "/usr/local/lib/python3.9/site-packages/click/_bashcomplete.py", line 122, in resolve_ctx
cmd_name, cmd, args = ctx.command.resolve_command(ctx, args)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1297, in resolve_command
cmd = self.get_command(ctx, cmd_name)
File "/usr/local/lib/python3.9/site-packages/utilities_common/cli.py", line 102, in get_command
**ctx.fail('Too many matches: %s' % ', '.join(sorted(matches)))**
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 550, in fail
raise UsageError(message, self)
click.exceptions.UsageError: Too many matches: inner-congested-bw-threshold, inner-full-notify-interval, inner-ldh-threshold, inner-notify-interval
Can only the error message be retained and the call stack is not printed?
Environment:
- Python version: 3.9
- 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
Read click/core.py around resolve_command and click/_bashcomplete.py around resolve_ctx and get_choices, then reproduce the invalid-parameter completion case described in the traceback. Check how the UsageError from get_command is surfaced during command-line association; done means the error message remains while the call stack is not printed.
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
- 48/100