-
Notifications
You must be signed in to change notification settings - Fork 302
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Who, What, and Why
As a user,
I want shell completion,
so that I do not need to memorise the CLI or rely on the CLI's help utility.
--> This allows a smoother CLI usage experience and potentially further improves CLI discoverability.
Specific scenarios:
- subcommand completion
- there are a lot of subcommands, will be great to be able to search through them and list them all out temporarily with shell completions
- option completion
- same reasoning as above
- argument completion
- subcommands such as
spotify_player get key <key>have arguments with specific values. Since they are nicely named but long, completion can speed this up by reducing risk of typo.
- subcommands such as
shell completion: custom TAB-completion available for some shells that requires custom script provided by the CLI program
some shells: clap_complete 4.4.4 provides bash, elvish, fish, powershell and zsh
How (roughly)
new dependencies
clap_complete: https://docs.rs/clap_complete/latest/clap_complete/index.htmlclap = "4.4.10"requiresclap_complete, our master branch is atclap = "4.4.10"as of [2023-12-04]
implementation directions
- provide subcommand that prints to stdout
- The documentation above included an example implementation that prints completion script to stdout.
- generate at build time
- The example for
generate_toincluded an implementation that generates completions within thebuild.rsscript during build time: https://docs.rs/clap_complete/latest/clap_complete/generator/fn.generate_to.html
- The example for
When
NOT urgent.
The CLI is already very much usable at the current state.
Other informations
spotify-tuiuses implementation direction 1, but they are usingclap = "2.33.3":
https://github.com/Rigellute/spotify-tui/blob/c4dcf6b9fd8318017acbdd7ec005955e26cf2794/src/main.rs#L171-L185- There was an issue with the said feature for
clap = "2.33.3"BUT it seems to be fixed since (clap = "4.3.11",clap_complete = "4.3.2"): zsh: optional flag with takes_value breaks completions clap-rs/clap#1822
Schnouki
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request