File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,11 +108,28 @@ pub enum Commands {
108108 /// Generate shell completions
109109 Completions {
110110 /// Shell to generate completions for
111- #[ arg( value_parser = [ "bash" , "zsh" , "fish" ] ) ]
112- shell : String ,
111+ #[ arg( value_enum ) ]
112+ shell : ShellChoice ,
113113 } ,
114114}
115115
116+ #[ derive( Clone , clap:: ValueEnum ) ]
117+ pub enum ShellChoice {
118+ Bash ,
119+ Zsh ,
120+ Fish ,
121+ }
122+
123+ impl From < ShellChoice > for clap_complete:: Shell {
124+ fn from ( s : ShellChoice ) -> Self {
125+ match s {
126+ ShellChoice :: Bash => clap_complete:: Shell :: Bash ,
127+ ShellChoice :: Zsh => clap_complete:: Shell :: Zsh ,
128+ ShellChoice :: Fish => clap_complete:: Shell :: Fish ,
129+ }
130+ }
131+ }
132+
116133#[ derive( Subcommand ) ]
117134pub enum AuthCommands {
118135 /// Remove authentication for a profile
Original file line number Diff line number Diff line change @@ -197,8 +197,8 @@ fn main() {
197197 }
198198 Commands :: Completions { shell } => {
199199 use clap:: CommandFactory ;
200- use clap_complete:: { Shell , generate} ;
201- let shell: Shell = shell. parse ( ) . unwrap ( ) ;
200+ use clap_complete:: generate;
201+ let shell: clap_complete :: Shell = shell. into ( ) ;
202202 let mut cmd = Cli :: command ( ) ;
203203 generate ( shell, & mut cmd, "hotdata" , & mut std:: io:: stdout ( ) ) ;
204204 }
You can’t perform that action at this time.
0 commit comments