solana-labs / solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://solanalabs.com
Apache License 2.0
13.15k stars 4.25k forks source link

cli: bash auto-completion for solana cli #14005

Open sotcsa opened 3 years ago

sotcsa commented 3 years ago

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

mvines commented 3 years ago

Yes please! I've wanted this for a while. I even naturally press TAB sometimes while typing solana ... and make myself sad.

t-nelson commented 3 years ago

Add another +1! The clap crate can allegedly do this for us, but I don't think anyone has been bothered enough to check it out. https://docs.rs/clap/2.33.3/clap/struct.App.html#method.gen_completions

CriesofCarrots commented 3 years ago

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

sotcsa commented 2 years ago

Great job!

Could you add to the docs how to use it? E.g.

solana completion > bin/solana_completion.sh
source bin/solana_completion.sh
hongquan commented 2 years ago

How to do with Zsh: https://quan.hoabinh.vn/blog/2022/10/104-enable-auto-completion-for-solana-cli