-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Auto-generate shell completions for solana-cli (issue #8879 and #14005) #18931
Auto-generate shell completions for solana-cli (issue #8879 and #14005) #18931
Conversation
…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.
CriesofCarrots
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've been wanting this for a while.
I actually don't think there's a strong reason the base_ and finalize_ parts of the App have to remain separate anymore. Wdyt about adding a separate module to hold the app-construction function?
@t-nelson , can you take a look at this as well?
t-nelson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I've been wanting these for awhile too
Agreed. Let's tie these up while they're getting shuffled around anyway |
Also join two parts of the construction into a single function
Codecov Report
@@ Coverage Diff @@
## master #18931 +/- ##
=========================================
- Coverage 82.8% 82.8% -0.1%
=========================================
Files 444 445 +1
Lines 126716 126846 +130
=========================================
+ Hits 104971 105063 +92
- Misses 21745 21783 +38 |
CriesofCarrots
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you so much!
… (#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 <[email protected]>
Implement
completionSubCommand for solana-cli, which outputscompletion 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
appfunction,and some other arguments and subcommands were added later directly in
the
mainfunction.Now: The whole construction of App was moved to
get_clap_appfunction.P.S. I wasn't sure if constructing App separately had visual importance,
so both constructing parts are still separate in
base_clap_appandfinalize_clap_appfunctions. But they sure could be one single function.Problem
Absence of shell completions in solana-cli. (#8879 and #14005)
Summary of Changes
completionsubcommand for solana-cli to generate completion scripts.Fixes #8879 and #14005