@@ -37,7 +37,7 @@ func (cmd *Command) writeFishCompletionTemplate(w io.Writer) error {
3737 // Add commands and their flags
3838 completions = append (
3939 completions ,
40- cmd .prepareFishCommands (cmd .VisibleCommands () , []string {})... ,
40+ cmd .prepareFishCommands (cmd .Commands , []string {})... ,
4141 )
4242
4343 toplevelCommandNames := []string {}
@@ -55,20 +55,22 @@ func (cmd *Command) writeFishCompletionTemplate(w io.Writer) error {
5555func (cmd * Command ) prepareFishCommands (commands []* Command , previousCommands []string ) []string {
5656 completions := []string {}
5757 for _ , command := range commands {
58- var completion strings.Builder
59- fmt .Fprintf (& completion ,
60- "complete -x -c %s -n '%s' -a '%s'" ,
61- cmd .Name ,
62- cmd .fishSubcommandHelper (previousCommands , commands ),
63- strings .Join (command .Names (), " " ),
64- )
65-
66- if command .Usage != "" {
58+ if ! command .Hidden {
59+ var completion strings.Builder
6760 fmt .Fprintf (& completion ,
68- " -d '%s'" ,
69- escapeSingleQuotes (command .Usage ))
61+ "complete -x -c %s -n '%s' -a '%s'" ,
62+ cmd .Name ,
63+ cmd .fishSubcommandHelper (previousCommands , commands ),
64+ strings .Join (command .Names (), " " ),
65+ )
66+
67+ if command .Usage != "" {
68+ fmt .Fprintf (& completion ,
69+ " -d '%s'" ,
70+ escapeSingleQuotes (command .Usage ))
71+ }
72+ completions = append (completions , completion .String ())
7073 }
71- completions = append (completions , completion .String ())
7274 completions = append (
7375 completions ,
7476 cmd .prepareFishFlags (command .VisibleFlags (), command .Names ())... ,
0 commit comments