Debian Codegraph @

command.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 "slicesscip-go gomod github.com/golang/go/src go1.22 slices/"
8 "stringsscip-go gomod github.com/golang/go/src go1.22 strings/"
9 )
10
11 const (
12 // ignoreFlagPrefix is to ignore test flags when adding flags from other packages
13 ignoreFlagPrefixscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ignoreFlagPrefix. = "test."
14
15 commandContextKeyscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandContextKey. = contextKeyscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/contextKey#("cli.context")
16 )
17
18 type contextKeyscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/contextKey# string
19
20 // Command contains everything needed to run an application that
21 // accepts a string slice of arguments such as os.Args. A given
22 // Command may contain Flags and sub-commands in Commands.
23 type Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# struct {
24 // The name of the command
25 Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name. string `json:"name"`
26 // A list of aliases for the command
27 Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Aliases. []string `json:"aliases"`
28 // A short description of the usage of this command
29 Usagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Usage. string `json:"usage"`
30 // Text to override the USAGE section of help
31 UsageTextscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#UsageText. string `json:"usageText"`
32 // A short description of the arguments of this command
33 ArgsUsagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ArgsUsage. string `json:"argsUsage"`
34 // Version of the command
35 Versionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Version. string `json:"version"`
36 // Longer explanation of how the command works
37 Descriptionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Description. string `json:"description"`
38 // DefaultCommand is the (optional) name of a command
39 // to run if no command names are passed as CLI arguments.
40 DefaultCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#DefaultCommand. string `json:"defaultCommand"`
41 // The category the command is part of
42 Categoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Category. string `json:"category"`
43 // List of child commands
44 Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands. []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# `json:"commands"`
45 // List of flags to parse
46 Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags. []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# `json:"flags"`
47 // Boolean to hide built-in help command and help flag
48 HideHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#HideHelp. bool `json:"hideHelp"`
49 // Ignored if HideHelp is true.
50 HideHelpCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#HideHelpCommand. bool `json:"hideHelpCommand"`
51 // Boolean to hide built-in version flag and the VERSION section of help
52 HideVersionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#HideVersion. bool `json:"hideVersion"`
53 // Boolean to enable shell completion commands
54 EnableShellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#EnableShellCompletion. bool `json:"-"`
55 // Shell Completion generation command name
56 ShellCompletionCommandNamescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ShellCompletionCommandName. string `json:"-"`
57 // The function to call when checking for shell command completions
58 ShellCompletescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ShellComplete. ShellCompleteFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShellCompleteFunc# `json:"-"`
59 // The function to configure a shell completion command
60 ConfigureShellCompletionCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ConfigureShellCompletionCommand. ConfigureShellCompletionCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ConfigureShellCompletionCommand# `json:"-"`
61 // An action to execute before any subcommands are run, but after the context is ready
62 // If a non-nil error is returned, no subcommands are run
63 Beforescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Before. BeforeFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/BeforeFunc# `json:"-"`
64 // An action to execute after any subcommands are run, but after the subcommand has finished
65 // It is run even if Action() panics
66 Afterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#After. AfterFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/AfterFunc# `json:"-"`
67 // The function to call when this command is invoked
68 Actionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Action. ActionFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ActionFunc# `json:"-"`
69 // Execute this function if the proper command cannot be found
70 CommandNotFoundscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#CommandNotFound. CommandNotFoundFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandNotFoundFunc# `json:"-"`
71 // Execute this function if a usage error occurs.
72 OnUsageErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#OnUsageError. OnUsageErrorFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/OnUsageErrorFunc# `json:"-"`
73 // Execute this function when an invalid flag is accessed from the context
74 InvalidFlagAccessHandlerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#InvalidFlagAccessHandler. InvalidFlagAccessFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/InvalidFlagAccessFunc# `json:"-"`
75 // Boolean to hide this command from help or completion
76 Hiddenscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Hidden. bool `json:"hidden"`
77 // List of all authors who contributed (string or fmt.Stringer)
78 // TODO: ~string | fmt.Stringer when interface unions are available
79 Authorsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Authors. []any `json:"authors"`
80 // Copyright of the binary if any
81 Copyrightscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Copyright. string `json:"copyright"`
82 // Reader reader to write input to (useful for tests)
83 Readerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Reader. ioscip-go gomod github.com/golang/go/src go1.22 io/.Readerscip-go gomod github.com/golang/go/src go1.22 io/Reader# `json:"-"`
84 // Writer writer to write output to
85 Writerscip-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# `json:"-"`
86 // ErrWriter writes error output
87 ErrWriterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ErrWriter. ioscip-go gomod github.com/golang/go/src go1.22 io/.Writerscip-go gomod github.com/golang/go/src go1.22 io/Writer# `json:"-"`
88 // ExitErrHandler processes any error encountered while running a Command before it is
89 // returned to the caller. If no function is provided, HandleExitCoder is used as the
90 // default behavior.
91 ExitErrHandlerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ExitErrHandler. ExitErrHandlerFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ExitErrHandlerFunc# `json:"-"`
92 // Other custom info
93 Metadatascip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Metadata. map[string]any `json:"metadata"`
94 // Carries a function which returns app specific info.
95 ExtraInfoscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ExtraInfo. func() map[string]string `json:"-"`
96 // CustomRootCommandHelpTemplate the text template for app help topic.
97 // cli.go uses text/template to render templates. You can
98 // render custom help text by setting this variable.
99 CustomRootCommandHelpTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#CustomRootCommandHelpTemplate. string `json:"-"`
100 // SliceFlagSeparator is used to customize the separator for SliceFlag, the default is ","
101 SliceFlagSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#SliceFlagSeparator. string `json:"sliceFlagSeparator"`
102 // DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false
103 DisableSliceFlagSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#DisableSliceFlagSeparator. bool `json:"disableSliceFlagSeparator"`
104 // MapFlagKeyValueSeparator is used to customize the separator for MapFlag, the default is "="
105 MapFlagKeyValueSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#MapFlagKeyValueSeparator. string `json:"mapFlagKeyValueSeparator"`
106 // Boolean to enable short-option handling so user can combine several
107 // single-character bool arguments into one
108 // i.e. foobar -o -v -> foobar -ov
109 UseShortOptionHandlingscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#UseShortOptionHandling. bool `json:"useShortOptionHandling"`
110 // Enable suggestions for commands and flags
111 Suggestscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Suggest. bool `json:"suggest"`
112 // Allows global flags set by libraries which use flag.XXXVar(...) directly
113 // to be parsed through this library
114 AllowExtFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#AllowExtFlags. bool `json:"allowExtFlags"`
115 // Treat all flags as normal arguments if true
116 SkipFlagParsingscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#SkipFlagParsing. bool `json:"skipFlagParsing"`
117 // CustomHelpTemplate the text template for the command help topic.
118 // cli.go uses text/template to render templates. You can
119 // render custom help text by setting this variable.
120 CustomHelpTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#CustomHelpTemplate. string `json:"-"`
121 // Use longest prefix match for commands
122 PrefixMatchCommandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#PrefixMatchCommands. bool `json:"prefixMatchCommands"`
123 // Custom suggest command for matching
124 SuggestCommandFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#SuggestCommandFunc. SuggestCommandFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/SuggestCommandFunc# `json:"-"`
125 // Flag exclusion group
126 MutuallyExclusiveFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#MutuallyExclusiveFlags. []MutuallyExclusiveFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags# `json:"mutuallyExclusiveFlags"`
127 // Arguments to parse for this command
128 Argumentsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Arguments. []Argumentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Argument# `json:"arguments"`
129 // Whether to read arguments from stdin
130 // applicable to root command only
131 ReadArgsFromStdinscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ReadArgsFromStdin. bool `json:"readArgsFromStdin"`
132 // StopOnNthArg provides v2-like behavior for specific commands by stopping
133 // flag parsing after N positional arguments are encountered. When set to N,
134 // all remaining arguments after the Nth positional argument will be treated
135 // as arguments, not flags.
136 //
137 // A value of 0 means all arguments are treated as positional (no flag parsing).
138 // A nil value means normal v3 flag parsing behavior (flags can appear anywhere).
139 StopOnNthArgscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#StopOnNthArg. *int `json:"stopOnNthArg"`
140
141 // categories contains the categorized commands and is populated on app startup
142 categoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#categories. CommandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategories#
143 // flagCategories contains the categorized flags and is populated on app startup
144 flagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#flagCategories. FlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagCategories#
145 // flags that have been applied in current parse
146 appliedFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#appliedFlags. []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#
147 // flags that have been set
148 setFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setFlags. map[Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#]struct{}
149 // The parent of this command. This value will be nil for the
150 // command at the root of the graph.
151 parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#
152 // parsed args
153 parsedArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parsedArgs. Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#
154 // track state of error handling
155 isInErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#isInError. bool
156 // track state of defaults
157 didSetupDefaultsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#didSetupDefaults. bool
158 // whether in shell completion mode
159 shellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#shellCompletion. bool
160 // whether global help flag was added
161 globaHelpFlagAddedscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#globaHelpFlagAdded. bool
162 // whether global version flag was added
163 globaVersionFlagAddedscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#globaVersionFlagAdded. bool
164 // generated root version flag
165 versionFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#versionFlag. Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#
166 // whether this is a completion command
167 isCompletionCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#isCompletionCommand. bool
168 // whether this is the built-in help command
169 builtInHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#builtInHelp. bool
170 }
171
172 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Command().(name string) *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# {
173 for _, subCmd := range cmd.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands. {
174 if subCmd.HasNamescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#HasName().(name) {
175 return subCmd
176 }
177 }
178
179 return nil
180 }
181
182 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) checkHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#checkHelp().() bool {
183 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("checking if help is wanted (cmd=%[1]q)", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
184
185 return HelpFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpFlag. != nil && slicesscip-go gomod github.com/golang/go/src go1.22 slices/.ContainsFuncscip-go gomod github.com/golang/go/src go1.22 slices/ContainsFunc().(HelpFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HelpFlag..Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.(), cmd.Boolscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Bool().)
186 }
187
188 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) allFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#allFlags().() []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# {
189 var flags []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#
190 flags = append(flags, cmd.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags....)
191 for _, grpf := range cmd.MutuallyExclusiveFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#MutuallyExclusiveFlags. {
192 for _, f1 := range grpf.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#Flags. {
193 flags = append(flags, f1...)
194 }
195 }
196 return flags
197 }
198
199 // useShortOptionHandling traverses Lineage() for *any* ancestors
200 // with UseShortOptionHandling
201 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) useShortOptionHandlingscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#useShortOptionHandling().() bool {
202 for _, pCmd := range cmd.Lineagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Lineage().() {
203 if pCmd.UseShortOptionHandlingscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#UseShortOptionHandling. {
204 return true
205 }
206 }
207
208 return false
209 }
210
211 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) suggestFlagFromErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#suggestFlagFromError().(err error, commandName string) (string, error) {
212 fl, parseErr := flagFromErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/flagFromError().(err)
213 if parseErr != nil {
214 return "", err
215 }
216
217 flags := cmd.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags.
218 hideHelp := cmd.hideHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#hideHelp().()
219
220 if commandName != "" {
221 subCmd := cmd.Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Command().(commandName)
222 if subCmd == nil {
223 return "", err
224 }
225 flags = subCmd.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags.
226 hideHelp = hideHelp || subCmd.HideHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#HideHelp.
227 }
228
229 suggestion := SuggestFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/SuggestFlag.(flags, fl, hideHelp)
230 if len(suggestion) == 0 {
231 return "", err
232 }
233
234 return fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Sprintf().(SuggestDidYouMeanTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/SuggestDidYouMeanTemplate., suggestion) + "\n\n", nil
235 }
236
237 // Names returns the names including short names and aliases.
238 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Names().() []string {
239 return append([]string{cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.}, cmd.Aliasesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Aliases....)
240 }
241
242 // HasName returns true if Command.Name matches given name
243 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) HasNamescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#HasName().(name string) bool {
244 return slicesscip-go gomod github.com/golang/go/src go1.22 slices/.Containsscip-go gomod github.com/golang/go/src go1.22 slices/Contains().(cmd.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Names().(), name)
245 }
246
247 // VisibleCategories returns a slice of categories and commands that are
248 // Hidden=false
249 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) VisibleCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#VisibleCategories().() []CommandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategory# {
250 ret := []CommandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategory#{}
251 for _, category := range cmd.categoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#categories..Categoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategories#Categories.() {
252 if visible := func() CommandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategory# {
253 if len(category.VisibleCommandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategory#VisibleCommands.()) > 0 {
254 return category
255 }
256 return nil
257 }(); visible != nil {
258 ret = append(ret, visible)
259 }
260 }
261 return ret
262 }
263
264 // VisibleCommands returns a slice of the Commands with Hidden=false
265 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) VisibleCommandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#VisibleCommands().() []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# {
266 var ret []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#
267 for _, command := range cmd.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands. {
268 if command.Hiddenscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Hidden. || command.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. {
269 continue
270 }
271 ret = append(ret, command)
272 }
273 return ret
274 }
275
276 // VisibleFlagCategories returns a slice containing all the visible flag categories with the flags they contain
277 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) VisibleFlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#VisibleFlagCategories().() []VisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlagCategory# {
278 if cmd.flagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#flagCategories. == nil {
279 cmd.flagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#flagCategories. = newFlagCategoriesFromFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/newFlagCategoriesFromFlags().(cmd.allFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#allFlags().())
280 }
281 return cmd.flagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#flagCategories..VisibleCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagCategories#VisibleCategories.()
282 }
283
284 // VisibleFlags returns a slice of the Flags with Hidden=false
285 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) VisibleFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#VisibleFlags().() []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# {
286 return visibleFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/visibleFlags().(cmd.allFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#allFlags().())
287 }
288
289 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) appendFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#appendFlag().(fl Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#) {
290 if !hasFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/hasFlag().(cmd.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags., fl) {
291 cmd.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags. = append(cmd.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags., fl)
292 }
293 }
294
295 // VisiblePersistentFlags returns a slice of [LocalFlag] with Persistent=true and Hidden=false.
296 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) VisiblePersistentFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#VisiblePersistentFlags().() []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# {
297 if cmd.isCompletionCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#isCompletionCommand. {
298 return nil
299 }
300 var flags []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#
301 for _, fl := range cmd.Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().().Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags. {
302 pfl, ok := fl.(LocalFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/LocalFlag#)
303 if !ok || pfl.IsLocalscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/LocalFlag#IsLocal.() {
304 continue
305 }
306 flags = append(flags, fl)
307 }
308 return visibleFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/visibleFlags().(flags)
309 }
310
311 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) appendCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#appendCommand().(aCmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) {
312 if !slicesscip-go gomod github.com/golang/go/src go1.22 slices/.Containsscip-go gomod github.com/golang/go/src go1.22 slices/Contains().(cmd.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands., aCmd) {
313 aCmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. = cmd
314 cmd.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands. = append(cmd.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands., aCmd)
315 }
316 }
317
318 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) handleExitCoderscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#handleExitCoder().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, err error) error {
319 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil {
320 return cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent..handleExitCoderscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#handleExitCoder().(ctx, err)
321 }
322
323 if cmd.ExitErrHandlerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ExitErrHandler. != nil {
324 cmd.ExitErrHandlerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ExitErrHandler.(ctx, cmd, err)
325 return err
326 }
327
328 HandleExitCoderscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/HandleExitCoder().(err)
329 return err
330 }
331
332 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) argsWithDefaultCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#argsWithDefaultCommand().(oldArgs Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#) Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args# {
333 rawArgs := append([]string{cmd.DefaultCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#DefaultCommand.}, oldArgs.Slicescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#Slice.()...)
334 newArgs := &stringSliceArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/stringSliceArgs#{vscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/stringSliceArgs#v.: rawArgs}
335
336 return newArgs
337 }
338
339 // Root returns the Command at the root of the graph
340 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().() *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# {
341 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. == nil {
342 return cmd
343 }
344
345 return cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent..Rootscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Root().()
346 }
347
348 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) setscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#set().(fName string, f Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#, val string) error {
349 cmd.setFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setFlags.[f] = struct{}{}
350 cmd.setMultiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setMultiValueParsingConfig().(f)
351 if err := f.Setscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Set.(fName, val); err != nil {
352 return fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.22 fmt/Errorf().("invalid value %q for flag -%s: %v", val, fName, err)
353 }
354 return nil
355 }
356
357 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) lFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#lFlag().(name string) Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# {
358 for _, f := range cmd.allFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#allFlags().() {
359 if slicesscip-go gomod github.com/golang/go/src go1.22 slices/.Containsscip-go gomod github.com/golang/go/src go1.22 slices/Contains().(f.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.(), name) {
360 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("flag found for name %[1]q (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
361 return f
362 }
363 }
364 return nil
365 }
366
367 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) hasPersistentFlagOnAncestorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#hasPersistentFlagOnAncestor().(fl Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#) bool {
368 for pCmd := cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent.; pCmd != nil; pCmd = pCmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. {
369 for _, pFl := range pCmd.allFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#allFlags().() {
370 if pFl != fl {
371 continue
372 }
373
374 pfl, ok := pFl.(LocalFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/LocalFlag#)
375 if ok && !pfl.IsLocalscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/LocalFlag#IsLocal.() {
376 return true
377 }
378 }
379 }
380 return false
381 }
382
383 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) lookupFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#lookupFlag().(name string) Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# {
384 for _, pCmd := range cmd.Lineagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Lineage().() {
385 if f := pCmd.lFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#lFlag().(name); f != nil {
386 return f
387 }
388 }
389
390 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("flag NOT found for name %[1]q (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
391 cmd.onInvalidFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#onInvalidFlag().(contextscip-go gomod github.com/golang/go/src go1.22 context/.TODOscip-go gomod github.com/golang/go/src go1.22 context/TODO().(), name)
392 return nil
393 }
394
395 // this looks up only allowed flags, i.e. local flags for current command
396 // or persistent flags from ancestors
397 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) lookupAppliedFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#lookupAppliedFlag().(name string) Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# {
398 for _, f := range cmd.appliedFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#appliedFlags. {
399 if slicesscip-go gomod github.com/golang/go/src go1.22 slices/.Containsscip-go gomod github.com/golang/go/src go1.22 slices/Contains().(f.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.(), name) {
400 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("appliedFlag found for name %[1]q (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
401 return f
402 }
403 }
404
405 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("lookupAppliedflag NOT found for name %[1]q (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
406 cmd.onInvalidFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#onInvalidFlag().(contextscip-go gomod github.com/golang/go/src go1.22 context/.TODOscip-go gomod github.com/golang/go/src go1.22 context/TODO().(), name)
407 return nil
408 }
409
410 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) checkRequiredFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#checkRequiredFlag().(f Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#) (bool, string) {
411 if rf, ok := f.(RequiredFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/RequiredFlag#); ok && rf.IsRequiredscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/RequiredFlag#IsRequired.() {
412 flagName := f.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.()[0]
413 if !f.IsSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#IsSet.() {
414 return false, flagName
415 }
416 }
417 return true, ""
418 }
419
420 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) checkAllRequiredFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#checkAllRequiredFlags().() requiredFlagsErrscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/requiredFlagsErr# {
421 // The help and completion commands are allowed to run without
422 // enforcement of required flags, since they do not invoke user
423 // actions that depend on those flag values.
424 if cmd.builtInHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#builtInHelp. || cmd.isCompletionCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#isCompletionCommand. {
425 return nil
426 }
427 for pCmd := cmd; pCmd != nil; pCmd = pCmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. {
428 if err := pCmd.checkRequiredFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#checkRequiredFlags().(); err != nil {
429 return err
430 }
431 }
432 return nil
433 }
434
435 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) checkRequiredFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#checkRequiredFlags().() requiredFlagsErrscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/requiredFlagsErr# {
436 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("checking for required flags (cmd=%[1]q)", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
437
438 missingFlags := []string{}
439
440 for _, f := range cmd.appliedFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#appliedFlags. {
441 if ok, name := cmd.checkRequiredFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#checkRequiredFlag().(f); !ok {
442 missingFlags = append(missingFlags, name)
443 }
444 }
445
446 if len(missingFlags) != 0 {
447 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("found missing required flags %[1]q (cmd=%[2]q)", missingFlags, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
448
449 return &errRequiredFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/errRequiredFlags#{missingFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/errRequiredFlags#missingFlags.: missingFlags}
450 }
451
452 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("all required flags set (cmd=%[1]q)", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
453
454 return nil
455 }
456
457 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) onInvalidFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#onInvalidFlag().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, name string) {
458 for cmd != nil {
459 if cmd.InvalidFlagAccessHandlerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#InvalidFlagAccessHandler. != nil {
460 cmd.InvalidFlagAccessHandlerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#InvalidFlagAccessHandler.(ctx, cmd, name)
461 break
462 }
463 cmd = cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent.
464 }
465 }
466
467 // NumFlags returns the number of flags set
468 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) NumFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#NumFlags().() int {
469 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("numFlags numAppliedFlags %d", len(cmd.appliedFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#appliedFlags.))
470 count := 0
471 for _, f := range cmd.appliedFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#appliedFlags. {
472 if f.IsSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#IsSet.() {
473 count++
474 }
475 }
476 return count // cmd.flagSet.NFlag()
477 }
478
479 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) setMultiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setMultiValueParsingConfig().(f Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#) {
480 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("setMultiValueParsingConfig %T, %+v", f, f)
481 if cf, ok := f.(multiValueParsingConfigSetterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfigSetter#); ok {
482 cf.setMultiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfigSetter#setMultiValueParsingConfig.(multiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfig#{
483 SliceFlagSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfig#SliceFlagSeparator.: cmd.SliceFlagSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#SliceFlagSeparator.,
484 DisableSliceFlagSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfig#DisableSliceFlagSeparator.: cmd.DisableSliceFlagSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#DisableSliceFlagSeparator.,
485 MapFlagKeyValueSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/multiValueParsingConfig#MapFlagKeyValueSeparator.: cmd.MapFlagKeyValueSeparatorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#MapFlagKeyValueSeparator.,
486 })
487 }
488 }
489
490 // Set sets a context flag to a value.
491 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Setscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Set().(name, value string) error {
492 if f := cmd.lookupFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#lookupFlag().(name); f != nil {
493 cmd.setMultiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setMultiValueParsingConfig().(f)
494 return f.Setscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Set.(name, value)
495 }
496
497 return fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.22 fmt/Errorf().("no such flag -%s", name)
498 }
499
500 // IsSet determines if the flag was actually set
501 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) IsSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#IsSet().(name string) bool {
502 fl := cmd.lookupFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#lookupFlag().(name)
503 if fl == nil {
504 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("flag with name %[1]q NOT found; assuming not set (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
505 return false
506 }
507
508 isSet := fl.IsSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#IsSet.()
509 if isSet {
510 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("flag with name %[1]q is set (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
511 } else {
512 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("flag with name %[1]q is no set (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
513 }
514
515 return isSet
516 }
517
518 // LocalFlagNames returns a slice of flag names used in this
519 // command.
520 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) LocalFlagNamesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#LocalFlagNames().() []string {
521 names := []string{}
522
523 // Check the flags which have been set via env or file
524 for _, f := range cmd.allFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#allFlags().() {
525 if f.IsSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#IsSet.() {
526 names = append(names, f.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.()...)
527 }
528 }
529
530 // Sort out the duplicates since flag could be set via multiple
531 // paths
532 m := map[string]struct{}{}
533 uniqNames := []string{}
534
535 for _, name := range names {
536 if _, ok := m[name]; !ok {
537 m[name] = struct{}{}
538 uniqNames = append(uniqNames, name)
539 }
540 }
541
542 return uniqNames
543 }
544
545 // FlagNames returns a slice of flag names used by the this command
546 // and all of its parent commands.
547 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) FlagNamesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#FlagNames().() []string {
548 names := cmd.LocalFlagNamesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#LocalFlagNames().()
549
550 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil {
551 names = append(cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent..FlagNamesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#FlagNames().(), names...)
552 }
553
554 return names
555 }
556
557 // Lineage returns *this* command and all of its ancestor commands
558 // in order from child to parent
559 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Lineagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Lineage().() []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# {
560 lineage := []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{cmd}
561
562 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil {
563 lineage = append(lineage, cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent..Lineagescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Lineage().()...)
564 }
565
566 return lineage
567 }
568
569 // FullName returns the full name of the command.
570 // Includes parent commands separated by space.
571 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) FullNamescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#FullName().() string {
572 return stringsscip-go gomod github.com/golang/go/src go1.22 strings/.Joinscip-go gomod github.com/golang/go/src go1.22 strings/Join().(cmd.Pathscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Path().(), " ")
573 }
574
575 // Path returns the path of command names from the root to cmd, inclusive.
576 // Each element is a Command.Name. Path traverses upward via parent pointers
577 // similar to Lineage. FullName() is equivalent to strings.Join(cmd.Path(), " ").
578 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Pathscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Path().() []string {
579 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil {
580 return append(cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent..Pathscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Path().(), cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
581 }
582 return []string{cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.}
583 }
584
585 // Walk visits cmd and every descendant. If fn returns a non-nil error, the
586 // walk terminates and the error is returned to the caller.
587 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Walkscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Walk().(fn func(*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) error) error {
588 if fn == nil {
589 return nil
590 }
591 if err := fn(cmd); err != nil {
592 return err
593 }
594 for _, sub := range cmd.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands. {
595 if err := sub.Walkscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Walk().(fn); err != nil {
596 return err
597 }
598 }
599 return nil
600 }
601
602 // Count returns the num of occurrences of this flag
603 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Countscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Count().(name string) int {
604 if cf, ok := cmd.lookupFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#lookupFlag().(name).(Countablescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Countable#); ok {
605 return cf.Countscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Countable#Count.()
606 }
607 return 0
608 }
609
610 // Value returns the value of the flag corresponding to `name`
611 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Valuescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Value().(name string) any {
612 if fs := cmd.lookupFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#lookupFlag().(name); fs != nil {
613 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("value found for name %[1]q (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
614 return fs.Getscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Get.()
615 }
616
617 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("value NOT found for name %[1]q (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
618 return nil
619 }
620
621 // Args returns the command line arguments associated with the
622 // command.
623 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Args().() Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args# {
624 return cmd.parsedArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parsedArgs.
625 }
626
627 // NArg returns the number of the command line arguments.
628 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) NArgscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#NArg().() int {
629 return cmd.Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Args().().Lenscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#Len.()
630 }
631
632 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) runFlagActionsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#runFlagActions().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#) error {
633 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("runFlagActions")
634 // run the flag actions in the same order that they are defined
635 // to maintain consistency.
636 for _, fl := range cmd.appliedFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#appliedFlags. {
637 if _, inSet := cmd.setFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setFlags.[fl]; inSet {
638 if af, ok := fl.(ActionableFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ActionableFlag#); ok {
639 if err := af.RunActionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ActionableFlag#RunAction.(ctx, cmd); err != nil {
640 return err
641 }
642 }
643 }
644 }
645
646 return nil
647 }