MCPcopy
hub / github.com/urfave/cli / prepareFishCommands

Function prepareFishCommands

fish.go:67–120  ·  fish.go::prepareFishCommands
(binary string, parent *Command)

Source from the content-addressed store, hash-verified

65}
66
67func prepareFishCommands(binary string, parent *Command) []string {
68 commands := parent.Commands
69 completions := []string{}
70 for _, command := range commands {
71 if !command.Hidden {
72 var completion strings.Builder
73 fmt.Fprintf(&completion,
74 "complete -x -c %s -n '%s' -a '%s'",
75 binary,
76 fishSubcommandHelper(binary, parent, commands),
77 command.Name,
78 )
79
80 if command.Usage != "" {
81 fmt.Fprintf(&completion,
82 " -d '%s'",
83 escapeSingleQuotes(command.Usage))
84 }
85 completions = append(completions, completion.String())
86 }
87
88 if command.ShellComplete != nil {
89 var completion strings.Builder
90 var path []string
91 lineage := command.Lineage()
92 for i := len(lineage) - 2; i >= 0; i-- {
93 path = append(path, lineage[i].Name)
94 }
95
96 fmt.Fprintf(&completion,
97 "complete -c %s -n '%s' -xa '(%s %s %s 2>/dev/null)'",
98 binary,
99 fishFlagHelper(binary, command),
100 binary,
101 strings.Join(path, " "),
102 completionFlag,
103 )
104 completions = append(completions, completion.String())
105 }
106
107 completions = append(
108 completions,
109 prepareFishFlags(binary, command)...,
110 )
111
112 // recursively iterate subcommands
113 completions = append(
114 completions,
115 prepareFishCommands(binary, command)...,
116 )
117 }
118
119 return completions
120}
121
122func prepareFishFlags(binary string, owner *Command) []string {
123 flags := owner.VisibleFlags()

Callers 1

Calls 6

fishSubcommandHelperFunction · 0.85
escapeSingleQuotesFunction · 0.85
fishFlagHelperFunction · 0.85
prepareFishFlagsFunction · 0.85
LineageMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected