Debian Codegraph @

help.go

raw symbols SCIP
1 package cliscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/
2
3 import (
4 "contextscip-go gomod github.com/golang/go/src go1.22 context/"
5 "fmtscip-go gomod github.com/golang/go/src go1.22 fmt/"
6 "ioscip-go gomod github.com/golang/go/src go1.22 io/"
7 "osscip-go gomod github.com/golang/go/src go1.22 os/"
8 "slicesscip-go gomod github.com/golang/go/src go1.22 slices/"
9 "stringsscip-go gomod github.com/golang/go/src go1.22 strings/"
10 "text/tabwriterscip-go gomod github.com/golang/go/src go1.22 `text/tabwriter`/"
11 "text/templatescip-go gomod github.com/golang/go/src go1.22 `text/template`/"
12 "unicode/utf8scip-go gomod github.com/golang/go/src go1.22 `unicode/utf8`/"
13 )
14
15 const (
16 helpNamescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpName. = "help"
17 helpAliasscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpAlias. = "h"
18 )
19
20 // HelpPrinterFunc prints help for the Command.
21 type HelpPrinterFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinterFunc# func(w ioscip-go gomod github.com/golang/go/src go1.22 io/.Writerscip-go gomod github.com/golang/go/src go1.22 io/Writer#, templ string, data any)
22
23 // Prints help for the Command with custom template function.
24 type HelpPrinterCustomFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinterCustomFunc# func(w ioscip-go gomod github.com/golang/go/src go1.22 io/.Writerscip-go gomod github.com/golang/go/src go1.22 io/Writer#, templ string, data any, customFunc map[string]any)
25
26 // HelpPrinter is a function that writes the help output. If not set explicitly,
27 // this calls HelpPrinterCustom using only the default template functions.
28 //
29 // If custom logic for printing help is required, this function can be
30 // overridden. If the ExtraInfo field is defined on a Command, this function
31 // should not be modified, as HelpPrinterCustom will be used directly in order
32 // to capture the extra information.
33 var HelpPrinterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinter. HelpPrinterFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinterFunc# = DefaultPrintHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultPrintHelp().
34
35 // HelpPrinterCustom is a function that writes the help output. It is used as
36 // the default implementation of HelpPrinter, and may be called directly if
37 // the ExtraInfo field is set on a Command.
38 //
39 // In the default implementation, if the customFuncs argument contains a
40 // "wrapAt" key, which is a function which takes no arguments and returns
41 // an int, this int value will be used to produce a "wrap" function used
42 // by the default template to wrap long lines.
43 var HelpPrinterCustomscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinterCustom. HelpPrinterCustomFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinterCustomFunc# = DefaultPrintHelpCustomscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultPrintHelpCustom().
44
45 // VersionPrinter prints the version for the root Command.
46 var VersionPrinterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VersionPrinter. = DefaultPrintVersionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultPrintVersion().
47
48 // ShowRootCommandHelp is an action that displays help for the root command.
49 var ShowRootCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowRootCommandHelp. = DefaultShowRootCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultShowRootCommandHelp().
50
51 // ShowAppHelp is a backward-compatible name for ShowRootCommandHelp.
52 var ShowAppHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowAppHelp. = ShowRootCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowRootCommandHelp.
53
54 // ShowCommandHelp prints help for the given command
55 var ShowCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowCommandHelp. = DefaultShowCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultShowCommandHelp().
56
57 // ShowSubcommandHelp prints help for the given subcommand
58 var ShowSubcommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowSubcommandHelp. = DefaultShowSubcommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultShowSubcommandHelp().
59
60 // UsageCommandHelp is the text to override the USAGE section of the help command
61 var UsageCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/UsageCommandHelp. = "Shows a list of commands or help for one command"
62
63 // ArgsUsageCommandHelp is a short description of the arguments of the help command
64 var ArgsUsageCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ArgsUsageCommandHelp. = "[command]"
65
66 func buildHelpCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildHelpCommand().(withAction bool) *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# {
67 cmd := &Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{
68 Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.: helpNamescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpName.,
69 Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Aliases.: []string{helpAliasscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpAlias.},
70 Usagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Usage.: UsageCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/UsageCommandHelp.,
71 ArgsUsagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ArgsUsage.: ArgsUsageCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ArgsUsageCommandHelp.,
72 HideHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#HideHelp.: true,
73 builtInHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#builtInHelp.: true,
74 }
75
76 if withAction {
77 cmd.Actionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Action. = helpCommandActionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpCommandAction().
78 }
79
80 return cmd
81 }
82
83 func helpCommandActionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpCommandAction().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) error {
84 args := cmd.Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Args().()
85 firstArg := args.Firstscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#First.()
86
87 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("doing help for cmd %[1]q with args %[2]q", cmd, args)
88
89 // helpCommandAction is triggered in several ways:
90 //
91 // * the command has no user-defined Action (default action fallback)
92 // * the --help / -h flag was parsed (via cmd.checkHelp())
93 // * the "help" subcommand (or "h" alias) was dispatched
94 //
95 // Possible invocations:
96 //
97 // $ app # default action; show root help
98 // $ app --help / -h # flag; show root help (ignores subsequent args)
99 // $ app help / h # subcommand; show root help
100 // $ app help / h foo # subcommand; show help for subcommand "foo"
101 // $ app --help / -h foo # flag; show help for subcommand "foo"
102 // $ app foo --help / -h # flag on subcommand; show help for "foo"
103 // $ app foo help / h # subcommand on subcommand; show help for "foo"
104 // $ app foo (no action) # default action on subcommand; show help for "foo"
105
106 // Case 4. when executing a help command set the context to parent
107 // to allow resolution of subsequent args. This will transform
108 // $ app help foo
109 // to
110 // $ app foo
111 // which will then be handled as case 3
112 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil && cmd.builtInHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#builtInHelp. {
113 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("setting cmd to cmd.parent")
114 cmd = cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent.
115 }
116
117 // Case 4. $ app help foo
118 // foo is the command for which help needs to be shown
119 if firstArg != "" {
120 /* if firstArg == "--" {
121 return nil
122 }*/
123 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("returning ShowCommandHelp with %[1]q", firstArg)
124 return ShowCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowCommandHelp.(ctx, cmd, firstArg)
125 }
126
127 // Case 1 & 2
128 // Special case when running help on main app itself as opposed to individual
129 // commands/subcommands
130 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. == nil {
131 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("returning ShowRootCommandHelp")
132 _ = ShowRootCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowRootCommandHelp.(cmd)
133 return nil
134 }
135
136 // Case 3, 5
137 if len(cmd.VisibleCommandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#VisibleCommands().()) == 0 {
138 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running HelpPrinter with command %[1]q", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
139 return ShowCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowCommandHelp.(ctx, cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent., cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
140 }
141
142 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running ShowSubcommandHelp")
143 return ShowSubcommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowSubcommandHelp.(cmd)
144 }
145
146 // ShowRootCommandHelpAndExit prints the list of subcommands and exits with exit code.
147 func ShowRootCommandHelpAndExitscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowRootCommandHelpAndExit().(cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#, exitCode int) {
148 _ = ShowRootCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowRootCommandHelp.(cmd)
149 OsExiterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/OsExiter.(exitCode)
150 }
151
152 // ShowAppHelpAndExit is a backward-compatible name for ShowRootCommandHelp.
153 var ShowAppHelpAndExitscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowAppHelpAndExit. = ShowRootCommandHelpAndExitscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowRootCommandHelpAndExit().
154
155 // DefaultShowRootCommandHelp is the default implementation of ShowRootCommandHelp.
156 func DefaultShowRootCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultShowRootCommandHelp().(cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) error {
157 tmpl := cmd.CustomRootCommandHelpTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#CustomRootCommandHelpTemplate.
158 if tmpl == "" {
159 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("using RootCommandHelpTemplate")
160 tmpl = RootCommandHelpTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/RootCommandHelpTemplate.
161 }
162
163 if cmd.ExtraInfoscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ExtraInfo. == nil {
164 HelpPrinterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinter.(cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().().Writerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Writer., tmpl, cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().())
165 return nil
166 }
167
168 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("setting ExtraInfo in customAppData")
169 customAppData := func() map[string]any {
170 return map[string]any{
171 "ExtraInfo": cmd.ExtraInfoscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ExtraInfo.,
172 }
173 }
174 HelpPrinterCustomscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinterCustom.(cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().().Writerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Writer., tmpl, cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().(), customAppData())
175
176 return nil
177 }
178
179 // DefaultRootCommandComplete prints the list of subcommands as the default completion method.
180 func DefaultRootCommandCompletescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultRootCommandComplete().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) {
181 DefaultCompleteWithFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultCompleteWithFlags().(ctx, cmd)
182 }
183
184 // DefaultAppComplete is a backward-compatible name for DefaultRootCommandComplete.
185 var DefaultAppCompletescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultAppComplete. = DefaultRootCommandCompletescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultRootCommandComplete().
186
187 func printCommandSuggestionsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/printCommandSuggestions().(commands []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#, writer ioscip-go gomod github.com/golang/go/src go1.22 io/.Writerscip-go gomod github.com/golang/go/src go1.22 io/Writer#) {
188 for _, command := range commands {
189 if command.Hiddenscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Hidden. {
190 continue
191 }
192 if len(command.Usagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Usage.) > 0 {
193 _, _ = fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Fprintf().(writer, "%s:%s\n", command.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name., command.Usagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Usage.)
194 } else {
195 _, _ = fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Fprintf().(writer, "%s\n", command.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
196 }
197 }
198 }
199
200 func cliArgContainsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/cliArgContains().(flagName string, args []string) bool {
201 for _, name := range stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Splitscip-go gomod github.com/golang/go/src go1.22 strings/Split().(flagName, ",") {
202 name = stringsscip-go gomod github.com/golang/go/src go1.22 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.22 strings/TrimSpace().(name)
203 count := utf8scip-go gomod github.com/golang/go/src go1.22 `unicode/utf8`/.RuneCountInStringscip-go gomod github.com/golang/go/src go1.22 `unicode/utf8`/RuneCountInString().(name)
204 if count > 2 {
205 count = 2
206 }
207 flag := fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Sprintf().("%s%s", stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Repeatscip-go gomod github.com/golang/go/src go1.22 strings/Repeat().("-", count), name)
208 if slicesscip-go gomod github.com/golang/go/src go1.22 slices/.Containsscip-go gomod github.com/golang/go/src go1.22 slices/Contains().(args, flag) {
209 return true
210 }
211 }
212 return false
213 }
214
215 func printFlagSuggestionsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/printFlagSuggestions().(lastArg string, flags []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#, writer ioscip-go gomod github.com/golang/go/src go1.22 io/.Writerscip-go gomod github.com/golang/go/src go1.22 io/Writer#) {
216 // Trim to handle both "-short" and "--long" flags.
217 cur := stringsscip-go gomod github.com/golang/go/src go1.22 strings/.TrimLeftscip-go gomod github.com/golang/go/src go1.22 strings/TrimLeft().(lastArg, "-")
218 for _, flag := range flags {
219 if bflag, ok := flag.(*BoolFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/BoolFlag#); ok && bflag.Hiddenscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Hidden. {
220 continue
221 }
222
223 usage := ""
224 if docFlag, ok := flag.(DocGenerationFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DocGenerationFlag#); ok {
225 usage = docFlag.GetUsagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DocGenerationFlag#GetUsage.()
226 }
227
228 name := stringsscip-go gomod github.com/golang/go/src go1.22 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.22 strings/TrimSpace().(flag.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.()[0])
229 // this will get total count utf8 letters in flag name
230 count := utf8scip-go gomod github.com/golang/go/src go1.22 `unicode/utf8`/.RuneCountInStringscip-go gomod github.com/golang/go/src go1.22 `unicode/utf8`/RuneCountInString().(name)
231 if count > 2 {
232 count = 2 // reuse this count to generate single - or -- in flag completion
233 }
234 // if flag name has more than one utf8 letter and last argument in cli has -- prefix then
235 // skip flag completion for short flags example -v or -x
236 if stringsscip-go gomod github.com/golang/go/src go1.22 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.22 strings/HasPrefix().(lastArg, "--") && count == 1 {
237 continue
238 }
239 // match if last argument matches this flag and it is not repeated
240 if stringsscip-go gomod github.com/golang/go/src go1.22 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.22 strings/HasPrefix().(name, cur) && cur != name /* && !cliArgContains(name, os.Args)*/ {
241 flagCompletion := fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Sprintf().("%s%s", stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Repeatscip-go gomod github.com/golang/go/src go1.22 strings/Repeat().("-", count), name)
242 if usage != "" {
243 flagCompletion = fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Sprintf().("%s:%s", flagCompletion, usage)
244 }
245 fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.22 fmt/Fprintln().(writer, flagCompletion)
246 }
247 }
248 }
249
250 func DefaultCompleteWithFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultCompleteWithFlags().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) {
251 args := osscip-go gomod github.com/golang/go/src go1.22 os/.Argsscip-go gomod github.com/golang/go/src go1.22 os/Args.
252 if cmd != nil && cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil {
253 args = cmd.Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Args().().Slicescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#Slice.()
254 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running default complete with flags[%v] on command %[2]q", args, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
255 } else {
256 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running default complete with os.Args flags[%v]", args)
257 }
258 argsLen := len(args)
259 lastArg := ""
260 // parent command will have --generate-shell-completion so we need
261 // to account for that
262 if argsLen > 1 {
263 lastArg = args[argsLen-2]
264 } else if argsLen > 0 {
265 lastArg = args[argsLen-1]
266 }
267
268 if lastArg == completionFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/completionFlag. {
269 lastArg = ""
270 }
271
272 if stringsscip-go gomod github.com/golang/go/src go1.22 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.22 strings/HasPrefix().(lastArg, "-") {
273 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("printing flag suggestion for flag[%v] on command %[1]q", lastArg, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
274 printFlagSuggestionsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/printFlagSuggestions().(lastArg, cmd.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags., cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().().Writerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Writer.)
275 return
276 }
277
278 if cmd != nil {
279 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("printing command suggestions on command %[1]q", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
280 printCommandSuggestionsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/printCommandSuggestions().(cmd.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands., cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().().Writerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Writer.)
281 return
282 }
283 }
284
285 // ShowCommandHelpAndExit exits with code after showing help via ShowCommandHelp.
286 func ShowCommandHelpAndExitscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowCommandHelpAndExit().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#, command string, code int) {
287 _ = ShowCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowCommandHelp.(ctx, cmd, command)
288 OsExiterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/OsExiter.(code)
289 }
290
291 // DefaultShowCommandHelp is the default implementation of ShowCommandHelp.
292 func DefaultShowCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultShowCommandHelp().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#, commandName string) error {
293 for _, subCmd := range cmd.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands. {
294 if !subCmd.HasNamescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#HasName().(commandName) {
295 continue
296 }
297
298 tmpl := subCmd.CustomHelpTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#CustomHelpTemplate.
299 if tmpl == "" {
300 if len(subCmd.VisibleCommandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#VisibleCommands().()) == 0 {
301 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("using CommandHelpTemplate")
302 tmpl = CommandHelpTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandHelpTemplate.
303 } else {
304 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("using SubcommandHelpTemplate")
305 tmpl = SubcommandHelpTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/SubcommandHelpTemplate.
306 }
307 }
308
309 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running HelpPrinter")
310 HelpPrinterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinter.(cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().().Writerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Writer., tmpl, subCmd)
311
312 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("returning nil after printing help")
313 return nil
314 }
315
316 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("no matching command found")
317
318 if cmd.CommandNotFoundscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#CommandNotFound. == nil {
319 errMsg := fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Sprintf().("No help topic for '%v'", commandName)
320
321 if cmd.Suggestscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Suggest. {
322 if suggestion := SuggestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/SuggestCommand.(cmd.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands., commandName); suggestion != "" {
323 errMsg += ". " + suggestion
324 }
325 }
326
327 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("exiting 3 with errMsg %[1]q", errMsg)
328 return Exitscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Exit().(errMsg, 3)
329 }
330
331 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running CommandNotFound func for %[1]q", commandName)
332 cmd.CommandNotFoundscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#CommandNotFound.(ctx, cmd, commandName)
333
334 return nil
335 }
336
337 // ShowSubcommandHelpAndExit prints help for the given subcommand via ShowSubcommandHelp and exits with exit code.
338 func ShowSubcommandHelpAndExitscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowSubcommandHelpAndExit().(cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#, exitCode int) {
339 _ = ShowSubcommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowSubcommandHelp.(cmd)
340 OsExiterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/OsExiter.(exitCode)
341 }
342
343 // DefaultShowSubcommandHelp is the default implementation of ShowSubcommandHelp.
344 func DefaultShowSubcommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultShowSubcommandHelp().(cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) error {
345 HelpPrinterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinter.(cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().().Writerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Writer., SubcommandHelpTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/SubcommandHelpTemplate., cmd)
346 return nil
347 }
348
349 // ShowVersion prints the version number of the root Command.
350 func ShowVersionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowVersion().(cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) {
351 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("showing version via VersionPrinter (cmd=%[1]q)", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
352 VersionPrinterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VersionPrinter.(cmd)
353 }
354
355 // DefaultPrintVersion is the default implementation of VersionPrinter.
356 func DefaultPrintVersionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultPrintVersion().(cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) {
357 _, _ = fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Fprintf().(cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().().Writerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Writer., "%v version %v\n", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name., cmd.Versionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Version.)
358 }
359
360 func handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err error) {
361 if err != nil {
362 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("error encountered during template parse: %[1]v", err)
363 // If the writer is closed, t.Execute will fail, and there's nothing
364 // we can do to recover.
365 if osscip-go gomod github.com/golang/go/src go1.22 os/.Getenvscip-go gomod github.com/golang/go/src go1.22 os/Getenv().("CLI_TEMPLATE_ERROR_DEBUG") != "" {
366 _, _ = fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Fprintf().(ErrWriterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ErrWriter., "CLI TEMPLATE ERROR: %#v\n", err)
367 }
368 return
369 }
370 }
371
372 // DefaultPrintHelpCustom is the default implementation of HelpPrinterCustom.
373 //
374 // The customFuncs map will be combined with a default template.FuncMap to
375 // allow using arbitrary functions in template rendering.
376 func DefaultPrintHelpCustomscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultPrintHelpCustom().(out ioscip-go gomod github.com/golang/go/src go1.22 io/.Writerscip-go gomod github.com/golang/go/src go1.22 io/Writer#, templ string, data any, customFuncs map[string]any) {
377 const maxLineLength = 10000
378
379 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("building default funcMap")
380 funcMap := templatescip-go gomod github.com/golang/go/src go1.22 `text/template`/.FuncMapscip-go gomod github.com/golang/go/src go1.22 `text/template`/FuncMap#{
381 "join": stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Joinscip-go gomod github.com/golang/go/src go1.22 strings/Join().,
382 "subtract": subtractscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/subtract().,
383 "indent": indentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/indent().,
384 "nindent": nindentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/nindent().,
385 "trim": stringsscip-go gomod github.com/golang/go/src go1.22 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.22 strings/TrimSpace().,
386 "wrap": func(input string, offset int) string { return wrapscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/wrap().(input, offset, maxLineLength) },
387 "offset": offsetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/offset().,
388 "offsetCommands": offsetCommandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/offsetCommands().,
389 }
390
391 if wa, ok := customFuncs["wrapAt"]; ok {
392 if wrapAtFunc, ok := wa.(func() int); ok {
393 wrapAt := wrapAtFunc()
394 customFuncs["wrap"] = func(input string, offset int) string {
395 return wrapscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/wrap().(input, offset, wrapAt)
396 }
397 }
398 }
399
400 for key, value := range customFuncs {
401 funcMap[key] = value
402 }
403
404 w := tabwriterscip-go gomod github.com/golang/go/src go1.22 `text/tabwriter`/.NewWriterscip-go gomod github.com/golang/go/src go1.22 `text/tabwriter`/NewWriter().(out, 1, 8, 2, ' ', 0)
405 t := templatescip-go gomod github.com/golang/go/src go1.22 `text/template`/.Mustscip-go gomod github.com/golang/go/src go1.22 `text/template`/Must().(templatescip-go gomod github.com/golang/go/src go1.22 `text/template`/.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/New().("help").Funcsscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Funcs().(funcMap).Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(templ))
406
407 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("helpNameTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(helpNameTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpNameTemplate.); err != nil {
408 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
409 }
410
411 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("argsTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(argsTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/argsTemplate.); err != nil {
412 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
413 }
414
415 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("usageTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(usageTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/usageTemplate.); err != nil {
416 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
417 }
418
419 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("descriptionTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(descriptionTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/descriptionTemplate.); err != nil {
420 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
421 }
422
423 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("visibleCommandTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(visibleCommandTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/visibleCommandTemplate.); err != nil {
424 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
425 }
426
427 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("copyrightTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(copyrightTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/copyrightTemplate.); err != nil {
428 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
429 }
430
431 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("versionTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(versionTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/versionTemplate.); err != nil {
432 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
433 }
434
435 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("visibleFlagCategoryTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(visibleFlagCategoryTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/visibleFlagCategoryTemplate.); err != nil {
436 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
437 }
438
439 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("visibleFlagTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(visibleFlagTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/visibleFlagTemplate.); err != nil {
440 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
441 }
442
443 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("visiblePersistentFlagTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(visiblePersistentFlagTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/visiblePersistentFlagTemplate.); err != nil {
444 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
445 }
446
447 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("visibleGlobalFlagCategoryTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(stringsscip-go gomod github.com/golang/go/src go1.22 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.22 strings/ReplaceAll().(visibleFlagCategoryTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/visibleFlagCategoryTemplate., "OPTIONS", "GLOBAL OPTIONS")); err != nil {
448 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
449 }
450
451 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("authorsTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(authorsTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/authorsTemplate.); err != nil {
452 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
453 }
454
455 if _, err := t.Newscip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#New().("visibleCommandCategoryTemplate").Parsescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Parse().(visibleCommandCategoryTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/visibleCommandCategoryTemplate.); err != nil {
456 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(err)
457 }
458
459 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("executing template")
460 handleTemplateErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/handleTemplateError().(t.Executescip-go gomod github.com/golang/go/src go1.22 `text/template`/Template#Execute().(w, data))
461
462 _ = w.Flushscip-go gomod github.com/golang/go/src go1.22 `text/tabwriter`/Writer#Flush().()
463 }
464
465 // DefaultPrintHelp is the default implementation of HelpPrinter.
466 func DefaultPrintHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/DefaultPrintHelp().(out ioscip-go gomod github.com/golang/go/src go1.22 io/.Writerscip-go gomod github.com/golang/go/src go1.22 io/Writer#, templ string, data any) {
467 HelpPrinterCustomscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpPrinterCustom.(out, templ, data, nil)
468 }
469
470 func checkVersionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/checkVersion().(cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) bool {
471 return cmd.versionFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#versionFlag. != nil && cmd.versionFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#versionFlag..IsSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#IsSet.()
472 }
473
474 func checkShellCompleteFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/checkShellCompleteFlag().(c *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#, arguments []string) (bool, []string) {
475 if (c.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. == nil && !c.EnableShellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#EnableShellCompletion.) || (c.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil && !c.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().().shellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#shellCompletion.) {
476 return false, arguments
477 }
478
479 pos := len(arguments) - 1
480 lastArg := arguments[pos]
481
482 if lastArg != completionFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/completionFlag. {
483 return false, arguments
484 }
485
486 // If arguments include "--" before the token being completed, shell completion
487 // is disabled because after "--" only positional arguments are accepted.
488 // https://unix.stackexchange.com/a/11382
489 // Note: The token being completed is at position pos-1 (immediately before completionFlag).
490 // We only check arguments before that position, so completing "--" itself still works.
491 if pos >= 1 && slicesscip-go gomod github.com/golang/go/src go1.22 slices/.Containsscip-go gomod github.com/golang/go/src go1.22 slices/Contains().(arguments[:pos-1], "--") {
492 return false, arguments[:pos]
493 }
494
495 return true, arguments[:pos]
496 }
497
498 func shouldRunCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/shouldRunCompletion().(cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) bool {
499 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("checking completions on command %[1]q", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
500
501 if !cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().().shellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#shellCompletion. {
502 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("completion not enabled skipping %[1]q", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
503 return false
504 }
505
506 if argsArguments := cmd.Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Args().(); argsArguments.Presentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#Present.() {
507 name := argsArguments.Firstscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#First.()
508 if cmd := cmd.Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Command().(name); cmd != nil {
509 // let the command handle the completion
510 return false
511 }
512 }
513
514 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("no subcommand found for completion %[1]q", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
515 return true
516 }
517
518 func runCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/runCompletion().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) {
519 if cmd.ShellCompletescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ShellComplete. != nil {
520 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running shell completion func for command %[1]q", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
521 cmd.ShellCompletescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ShellComplete.(ctx, cmd)
522 }
523 }
524
525 func subtractscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/subtract().(a, b int) int {
526 return a - b
527 }
528
529 func indentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/indent().(spaces int, v string) string {
530 pad := stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Repeatscip-go gomod github.com/golang/go/src go1.22 strings/Repeat().(" ", spaces)
531 return pad + stringsscip-go gomod github.com/golang/go/src go1.22 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.22 strings/ReplaceAll().(v, "\n", "\n"+pad)
532 }
533
534 func nindentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/nindent().(spaces int, v string) string {
535 return "\n" + indentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/indent().(spaces, v)
536 }
537
538 func wrapscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/wrap().(input string, offset int, wrapAt int) string {
539 var ss []string
540
541 lines := stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Splitscip-go gomod github.com/golang/go/src go1.22 strings/Split().(input, "\n")
542
543 padding := stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Repeatscip-go gomod github.com/golang/go/src go1.22 strings/Repeat().(" ", offset)
544
545 for i, line := range lines {
546 if line == "" {
547 ss = append(ss, line)
548 } else {
549 wrapped := wrapLinescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/wrapLine().(line, offset, wrapAt, padding)
550 if i == 0 {
551 ss = append(ss, wrapped)
552 } else {
553 ss = append(ss, padding+wrapped)
554 }
555
556 }
557 }
558
559 return stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Joinscip-go gomod github.com/golang/go/src go1.22 strings/Join().(ss, "\n")
560 }
561
562 func wrapLinescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/wrapLine().(input string, offset int, wrapAt int, padding string) string {
563 if wrapAt <= offset || len(input) <= wrapAt-offset {
564 return input
565 }
566
567 lineWidth := wrapAt - offset
568 words := stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Fieldsscip-go gomod github.com/golang/go/src go1.22 strings/Fields().(input)
569 if len(words) == 0 {
570 return input
571 }
572
573 wrapped := words[0]
574 spaceLeft := lineWidth - len(wrapped)
575 for _, word := range words[1:] {
576 if len(word)+1 > spaceLeft {
577 wrapped += "\n" + padding + word
578 spaceLeft = lineWidth - len(word)
579 } else {
580 wrapped += " " + word
581 spaceLeft -= 1 + len(word)
582 }
583 }
584
585 return wrapped
586 }
587
588 func offsetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/offset().(input string, fixed int) int {
589 return len(input) + fixed
590 }
591
592 // this function tries to find the max width of the names column
593 // so say we have the following rows for help
594 //
595 // foo1, foo2, foo3 some string here
596 // bar1, b2 some other string here
597 //
598 // We want to offset the 2nd row usage by some amount so that everything
599 // is aligned
600 //
601 // foo1, foo2, foo3 some string here
602 // bar1, b2 some other string here
603 //
604 // to find that offset we find the length of all the rows and use the max
605 // to calculate the offset
606 func offsetCommandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/offsetCommands().(cmds []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#, fixed int) int {
607 max := 0
608 for _, cmd := range cmds {
609 s := stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Joinscip-go gomod github.com/golang/go/src go1.22 strings/Join().(cmd.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Names().(), ", ")
610 if len(s) > max {
611 max = len(s)
612 }
613 }
614 return max + fixed
615 }