@@ -72,10 +72,13 @@ fn escape_help<T: ToString>(help: Option<&StyledStr>, data: T) -> String {
7272fn generate_inner ( p : & Command , previous_command_name : & str ) -> String {
7373 debug ! ( "generate_inner" ) ;
7474
75- let command_name = if previous_command_name. is_empty ( ) {
76- p. get_bin_name ( ) . expect ( INTERNAL_ERROR_MSG ) . to_string ( )
75+ let command_names = if previous_command_name. is_empty ( ) {
76+ vec ! [ p. get_bin_name( ) . expect( INTERNAL_ERROR_MSG ) . to_string( ) ]
7777 } else {
78- format ! ( "{};{}" , previous_command_name, & p. get_name( ) )
78+ p. get_name_and_visible_aliases ( )
79+ . into_iter ( )
80+ . map ( |name| format ! ( "{};{}" , previous_command_name, name) )
81+ . collect ( )
7982 } ;
8083
8184 let mut completions = String :: new ( ) ;
@@ -90,27 +93,31 @@ fn generate_inner(p: &Command, previous_command_name: &str) -> String {
9093 }
9194
9295 for subcommand in p. get_subcommands ( ) {
93- let data = & subcommand. get_name ( ) ;
94- let tooltip = escape_help ( subcommand. get_about ( ) , data) ;
95-
96- completions. push_str ( & preamble) ;
97- completions. push_str (
98- format ! ( "'{data}', '{data}', [CompletionResultType]::ParameterValue, '{tooltip}')" )
99- . as_str ( ) ,
100- ) ;
96+ for name in subcommand. get_name_and_visible_aliases ( ) {
97+ let tooltip = escape_help ( subcommand. get_about ( ) , name) ;
98+ completions. push_str ( & preamble) ;
99+ completions. push_str ( & format ! (
100+ "'{name}', '{name}', [CompletionResultType]::ParameterValue, '{tooltip}')"
101+ ) ) ;
102+ }
101103 }
102104
103- let mut subcommands_cases = format ! (
104- r"
105+ let mut subcommands_cases = String :: new ( ) ;
106+ for command_name in & command_names {
107+ subcommands_cases. push_str ( & format ! (
108+ r"
105109 '{}' {{{}
106110 break
107111 }}" ,
108- & command_name, completions
109- ) ;
112+ command_name, completions
113+ ) ) ;
114+ }
110115
111116 for subcommand in p. get_subcommands ( ) {
112- let subcommand_subcommands_cases = generate_inner ( subcommand, & command_name) ;
113- subcommands_cases. push_str ( & subcommand_subcommands_cases) ;
117+ for command_name in & command_names {
118+ let subcommand_subcommands_cases = generate_inner ( subcommand, command_name) ;
119+ subcommands_cases. push_str ( & subcommand_subcommands_cases) ;
120+ }
114121 }
115122
116123 subcommands_cases
0 commit comments