mirror of
https://github.com/clap-rs/clap
synced 2024-12-15 07:12:32 +00:00
9ee45f7f3d
This continues the work started with the fix for #4273. There was another bug caused by using the subcommand names without considering their position in the argument list. If the user enters `git diff log <TAB>`, we build up a string that identifies the subcommand. We ended up making the string `git__diff__log` in this case because we appended `__log` without considering the current state. Since `git__diff__log` does not correspond to an actual command, we wouldn't provide any suggestions. This commit restructures the code so we walk subcommands and subsubcommands in `bash.rs`. While walking those, we build up a list containing triples of the parent `$cmd` name (e.g. `git__diff`), the current command's name (e.g. `log`), and the `$cmd` for the current command. We then build the shell script's case arms based on that information. We could instead have fixed #4280 by using the second element in the pair returned from `utils::all_subcommands()` (a stringified list of the subcommand path) instead of the first one. However, that would not have helped us solve #4265. Closes #4280 |
||
---|---|---|
.. | ||
aliases.bash | ||
aliases.elvish | ||
aliases.fish | ||
aliases.ps1 | ||
aliases.zsh | ||
basic.bash | ||
basic.elvish | ||
basic.fish | ||
basic.ps1 | ||
basic.zsh | ||
feature_sample.bash | ||
feature_sample.elvish | ||
feature_sample.fish | ||
feature_sample.ps1 | ||
feature_sample.zsh | ||
quoting.bash | ||
quoting.elvish | ||
quoting.fish | ||
quoting.ps1 | ||
quoting.zsh | ||
register_minimal.bash | ||
special_commands.bash | ||
special_commands.elvish | ||
special_commands.fish | ||
special_commands.ps1 | ||
special_commands.zsh | ||
sub_subcommands.bash | ||
sub_subcommands.elvish | ||
sub_subcommands.fish | ||
sub_subcommands.ps1 | ||
sub_subcommands.zsh | ||
value_hint.bash | ||
value_hint.elvish | ||
value_hint.fish | ||
value_hint.ps1 | ||
value_hint.zsh |