-
Notifications
You must be signed in to change notification settings - Fork 4.5k
cli: bash auto-completion for solana cli #14005
Comments
Yes please! I've wanted this for a while. I even naturally press TAB sometimes while typing |
Add another +1! The |
…and solana-labs#14005) Implement `completion` SubCommand for solana-cli, which outputs completion script to stdout and exits the process. The script generation handled completely by clap. In order to implement the generation, one minor design change was necessary regarding the creation of clap `App`. Previously: One part of App initialization was in the `app` function, and some other arguments and subcommands were added later directly in the `main` function. Now: The whole construction of App was moved to `get_clap_app` function. P.S. I wasn't sure if constructing App separately had visual importance, so both constructing parts are still separate in `base_clap_app` and `final_clap_app` functions. But they sure could be in one single function.
… (#18931) * Auto-generate shell completions for solana-cli (issue #8879 and #14005) Implement `completion` SubCommand for solana-cli, which outputs completion script to stdout and exits the process. The script generation handled completely by clap. In order to implement the generation, one minor design change was necessary regarding the creation of clap `App`. Previously: One part of App initialization was in the `app` function, and some other arguments and subcommands were added later directly in the `main` function. Now: The whole construction of App was moved to `get_clap_app` function. P.S. I wasn't sure if constructing App separately had visual importance, so both constructing parts are still separate in `base_clap_app` and `final_clap_app` functions. But they sure could be in one single function. * Dereplicode match expr, fix clippy warning. * Move clap App construction into separate module Also join two parts of the construction into a single function * Fix tests * Apply rustfmt lints
… (#18931) * Auto-generate shell completions for solana-cli (issue #8879 and #14005) Implement `completion` SubCommand for solana-cli, which outputs completion script to stdout and exits the process. The script generation handled completely by clap. In order to implement the generation, one minor design change was necessary regarding the creation of clap `App`. Previously: One part of App initialization was in the `app` function, and some other arguments and subcommands were added later directly in the `main` function. Now: The whole construction of App was moved to `get_clap_app` function. P.S. I wasn't sure if constructing App separately had visual importance, so both constructing parts are still separate in `base_clap_app` and `final_clap_app` functions. But they sure could be in one single function. * Dereplicode match expr, fix clippy warning. * Move clap App construction into separate module Also join two parts of the construction into a single function * Fix tests * Apply rustfmt lints (cherry picked from commit 9d0a937)
… (#18931) (#18945) * Auto-generate shell completions for solana-cli (issue #8879 and #14005) Implement `completion` SubCommand for solana-cli, which outputs completion script to stdout and exits the process. The script generation handled completely by clap. In order to implement the generation, one minor design change was necessary regarding the creation of clap `App`. Previously: One part of App initialization was in the `app` function, and some other arguments and subcommands were added later directly in the `main` function. Now: The whole construction of App was moved to `get_clap_app` function. P.S. I wasn't sure if constructing App separately had visual importance, so both constructing parts are still separate in `base_clap_app` and `final_clap_app` functions. But they sure could be in one single function. * Dereplicode match expr, fix clippy warning. * Move clap App construction into separate module Also join two parts of the construction into a single function * Fix tests * Apply rustfmt lints (cherry picked from commit 9d0a937) Co-authored-by: theonekeyg <34949189+theonekeyg@users.noreply.github.com>
solana-cli can now generate a shell completion script, but I've left this issue open because we still lack docs about how to enable. Maybe something like this? https://github.com/rust-lang/rustup/blob/master/doc/src/installation/index.md#enable-tab-completion-for-bash-fish-zsh-or-powershell |
Great job! Could you add to the docs how to use it?
|
How to do with Zsh: https://quan.hoabinh.vn/blog/2022/10/104-enable-auto-completion-for-solana-cli |
Problem
Linux based solana command-line tool has no bash-autocomplete script, it would be perfect and easy to use on Linux (even on Mac)
Proposed Solution
Implement solana-completion.bash, add to README how to set it up.
source ./solana-completion.bash
Examples:
Docker: https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker
docker-compose: https://docs.docker.com/compose/completion/
Article on how to implement (with other useful links):
https://iridakos.com/programming/2018/03/01/bash-programmable-completion-tutorial
I am volunteering if nobody else is interestid
The text was updated successfully, but these errors were encountered: