@@ -551,14 +551,27 @@ pub struct LogoutCommand {
551551#[ derive( Args ) ]
552552pub struct CompletionCommand {
553553 /// Shell to generate completions for.
554- #[ arg( value_enum ) ]
554+ #[ arg( value_parser = parse_completion_shell ) ]
555555 pub shell : Option < clap_complete:: Shell > ,
556556
557557 /// Install completions to your shell configuration file.
558558 #[ arg( long = "install" ) ]
559559 pub install : bool ,
560560}
561561
562+ fn parse_completion_shell ( value : & str ) -> Result < clap_complete:: Shell , String > {
563+ match value. to_ascii_lowercase ( ) . as_str ( ) {
564+ "bash" => Ok ( clap_complete:: Shell :: Bash ) ,
565+ "elvish" => Ok ( clap_complete:: Shell :: Elvish ) ,
566+ "fish" => Ok ( clap_complete:: Shell :: Fish ) ,
567+ "powershell" | "pwsh" => Ok ( clap_complete:: Shell :: PowerShell ) ,
568+ "zsh" => Ok ( clap_complete:: Shell :: Zsh ) ,
569+ _ => Err ( format ! (
570+ "invalid shell '{value}'; expected one of bash, elvish, fish, powershell, pwsh, zsh"
571+ ) ) ,
572+ }
573+ }
574+
562575/// Init command - initialize AGENTS.md.
563576#[ derive( Args ) ]
564577pub struct InitCommand {
@@ -1754,6 +1767,17 @@ mod tests {
17541767 }
17551768 }
17561769
1770+ #[ test]
1771+ fn test_completion_command_pwsh_alias ( ) {
1772+ let cli = Cli :: try_parse_from ( [ "cortex" , "completion" , "pwsh" ] )
1773+ . expect ( "should parse completion pwsh" ) ;
1774+ if let Some ( Commands :: Completion ( completion) ) = cli. command {
1775+ assert_eq ! ( completion. shell, Some ( clap_complete:: Shell :: PowerShell ) ) ;
1776+ } else {
1777+ panic ! ( "Expected Completion command" ) ;
1778+ }
1779+ }
1780+
17571781 #[ test]
17581782 fn test_completion_command_install ( ) {
17591783 let cli = Cli :: try_parse_from ( [ "cortex" , "completion" , "--install" ] )
0 commit comments