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

Function prepareFishFlags

fish.go:122–163  ·  fish.go::prepareFishFlags
(binary string, owner *Command)

Source from the content-addressed store, hash-verified

120}
121
122func prepareFishFlags(binary string, owner *Command) []string {
123 flags := owner.VisibleFlags()
124 completions := []string{}
125 for _, f := range flags {
126 completion := &strings.Builder{}
127 fmt.Fprintf(completion,
128 "complete -c %s -n '%s'",
129 binary,
130 fishFlagHelper(binary, owner),
131 )
132
133 fishAddFileFlag(f, completion)
134
135 for idx, opt := range f.Names() {
136 if idx == 0 {
137 fmt.Fprintf(completion,
138 " -l %s", strings.TrimSpace(opt),
139 )
140 } else {
141 fmt.Fprintf(completion,
142 " -s %s", strings.TrimSpace(opt),
143 )
144 }
145 }
146
147 if flag, ok := f.(DocGenerationFlag); ok {
148 if flag.TakesValue() {
149 completion.WriteString(" -r")
150 }
151
152 if flag.GetUsage() != "" {
153 fmt.Fprintf(completion,
154 " -d '%s'",
155 escapeSingleQuotes(flag.GetUsage()))
156 }
157 }
158
159 completions = append(completions, completion.String())
160 }
161
162 return completions
163}
164
165func fishAddFileFlag(flag Flag, completion *strings.Builder) {
166 switch f := flag.(type) {

Callers 2

prepareFishCommandsFunction · 0.85

Calls 8

fishFlagHelperFunction · 0.85
fishAddFileFlagFunction · 0.85
escapeSingleQuotesFunction · 0.85
VisibleFlagsMethod · 0.80
NamesMethod · 0.65
TakesValueMethod · 0.65
GetUsageMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected