forked from clap-rs/clap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(complete): make
git diff log <TAB>
Bash-complete for git diff
This continues the work started with the fix for clap-rs#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 clap-rs#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 clap-rs#4265. Closes clap-rs#4280
- Loading branch information
1 parent
273115e
commit 71c4f1f
Showing
6 changed files
with
79 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters