Debian Codegraph @

command_run.go

raw symbols SCIP
1 package cliscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/
2
3 import (
4 "bufioscip-go gomod github.com/golang/go/src go1.22 bufio/"
5 "contextscip-go gomod github.com/golang/go/src go1.22 context/"
6 "fmtscip-go gomod github.com/golang/go/src go1.22 fmt/"
7 "ioscip-go gomod github.com/golang/go/src go1.22 io/"
8 "slicesscip-go gomod github.com/golang/go/src go1.22 slices/"
9 "unicodescip-go gomod github.com/golang/go/src go1.22 unicode/"
10 )
11
12 type helpShownKeyscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpShownKey# struct{}
13
14 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) parseArgsFromStdinscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parseArgsFromStdin().() ([]string, error) {
15 type state int
16 const (
17 stateSearchForToken state = -1
18 stateSearchForString state = 0
19 )
20
21 st := stateSearchForToken
22 linenum := 1
23 token := ""
24 args := []string{}
25
26 breader := bufioscip-go gomod github.com/golang/go/src go1.22 bufio/.NewReaderscip-go gomod github.com/golang/go/src go1.22 bufio/NewReader().(cmd.Readerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Reader.)
27
28 outer:
29 for {
30 ch, _, err := breader.ReadRunescip-go gomod github.com/golang/go/src go1.22 bufio/Reader#ReadRune().()
31 if err == ioscip-go gomod github.com/golang/go/src go1.22 io/.EOFscip-go gomod github.com/golang/go/src go1.22 io/EOF. {
32 switch st {
33 case stateSearchForToken:
34 if token != "--" {
35 args = append(args, token)
36 }
37 case stateSearchForString:
38 // make sure string is not empty
39 for _, t := range token {
40 if !unicodescip-go gomod github.com/golang/go/src go1.22 unicode/.IsSpacescip-go gomod github.com/golang/go/src go1.22 unicode/IsSpace().(t) {
41 args = append(args, token)
42 }
43 }
44 }
45 break outer
46 }
47 if err != nil {
48 return nil, err
49 }
50 switch st {
51 case stateSearchForToken:
52 if unicodescip-go gomod github.com/golang/go/src go1.22 unicode/.IsSpacescip-go gomod github.com/golang/go/src go1.22 unicode/IsSpace().(ch) || ch == '"' {
53 if ch == '\n' {
54 linenum++
55 }
56 if token != "" {
57 // end the processing here
58 if token == "--" {
59 break outer
60 }
61 args = append(args, token)
62 token = ""
63 }
64 if ch == '"' {
65 st = stateSearchForString
66 }
67 continue
68 }
69 token += string(ch)
70 case stateSearchForString:
71 if ch != '"' {
72 token += string(ch)
73 } else {
74 if token != "" {
75 args = append(args, token)
76 token = ""
77 }
78 /*else {
79 //TODO. Should we pass in empty strings ?
80 }*/
81 st = stateSearchForToken
82 }
83 }
84 }
85
86 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("parsed stdin args as %v (cmd=%[2]q)", args, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
87
88 return args, nil
89 }
90
91 // Run is the entry point to the command graph. The positional
92 // arguments are parsed according to the Flag and Command
93 // definitions and the matching Action functions are run.
94 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) Runscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Run().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, osArgs []string) (deferErr error) {
95 _, deferErr = cmd.runscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#run().(ctx, osArgs)
96 return deferErr
97 }
98
99 func (cmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) runscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#run().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, osArgs []string) (_ contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, deferErr error) {
100 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running with arguments %[1]q (cmd=%[2]q)", osArgs, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
101 cmd.setupDefaultsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setupDefaults().(osArgs)
102
103 // Validate StopOnNthArg
104 if cmd.StopOnNthArgscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#StopOnNthArg. != nil && *cmd.StopOnNthArgscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#StopOnNthArg. < 0 {
105 return ctx, fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.22 fmt/Errorf().("StopOnNthArg must be non-negative, got %d", *cmd.StopOnNthArgscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#StopOnNthArg.)
106 }
107
108 if v, ok := ctx.Valuescip-go gomod github.com/golang/go/src go1.22 context/Context#Value().(commandContextKeyscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandContextKey.).(*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#); ok {
109 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("setting parent (cmd=%[1]q) command from context.Context value (cmd=%[2]q)", v.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name., cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
110 cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. = v
111 }
112
113 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. == nil {
114 if cmd.ReadArgsFromStdinscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ReadArgsFromStdin. {
115 if args, err := cmd.parseArgsFromStdinscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parseArgsFromStdin().(); err != nil {
116 return ctx, err
117 } else {
118 osArgs = append(osArgs, args...)
119 }
120 }
121 // handle the completion flag separately from the flagset since
122 // completion could be attempted after a flag, but before its value was put
123 // on the command line. this causes the flagset to interpret the completion
124 // flag name as the value of the flag before it which is undesirable
125 // note that we can only do this because the shell autocomplete function
126 // always appends the completion flag at the end of the command
127 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("checking osArgs %v (cmd=%[2]q)", osArgs, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
128 cmd.shellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#shellCompletion., osArgs = checkShellCompleteFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/checkShellCompleteFlag().(cmd, osArgs)
129
130 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("setting cmd.shellCompletion=%[1]v from checkShellCompleteFlag (cmd=%[2]q)", cmd.shellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#shellCompletion. && cmd.EnableShellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#EnableShellCompletion., cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
131 cmd.shellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#shellCompletion. = cmd.EnableShellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#EnableShellCompletion. && cmd.shellCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#shellCompletion.
132 }
133
134 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("using post-checkShellCompleteFlag arguments %[1]q (cmd=%[2]q)", osArgs, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
135
136 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("setting self as cmd in context (cmd=%[1]q)", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
137 ctx = contextscip-go gomod github.com/golang/go/src go1.22 context/.WithValuescip-go gomod github.com/golang/go/src go1.22 context/WithValue().(ctx, commandContextKeyscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandContextKey., cmd)
138
139 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. == nil {
140 cmd.setupCommandGraphscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setupCommandGraph().()
141 }
142
143 var rargs Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args# = &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.: osArgs}
144 var args Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args# = &stringSliceArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/stringSliceArgs#{rargs.Tailscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#Tail.()}
145
146 for _, f := range cmd.allFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#allFlags().() {
147 if cmd.hasPersistentFlagOnAncestorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#hasPersistentFlagOnAncestor().(f) {
148 continue
149 }
150 if err := f.PreParsescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#PreParse.(); err != nil {
151 return ctx, err
152 }
153 }
154
155 var err error
156
157 if cmd.SkipFlagParsingscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#SkipFlagParsing. {
158 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("skipping flag parsing (cmd=%[1]q)", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
159 cmd.parsedArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parsedArgs. = args
160 } else {
161 cmd.parsedArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parsedArgs., err = cmd.parseFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parseFlags().(args)
162 }
163
164 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("using post-parse arguments %[1]q (cmd=%[2]q)", args, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
165
166 if shouldRunCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/shouldRunCompletion().(cmd) {
167 var beforeErr error
168 if ctx, beforeErr = runBeforescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/runBefore().(ctx, commandChainscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandChain().(cmd)); beforeErr != nil {
169 return ctx, beforeErr
170 }
171 runCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/runCompletion().(ctx, cmd)
172 return ctx, nil
173 }
174
175 if err != nil {
176 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("setting deferErr from %[1]q (cmd=%[2]q)", err, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
177 deferErr = err
178
179 cmd.isInErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#isInError. = true
180 if cmd.checkHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#checkHelp().() {
181 ctx = contextscip-go gomod github.com/golang/go/src go1.22 context/.WithValuescip-go gomod github.com/golang/go/src go1.22 context/WithValue().(ctx, helpShownKeyscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpShownKey#{}, true)
182 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. == nil {
183 _ = ShowRootCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowRootCommandHelp.(cmd)
184 } else {
185 _ = ShowSubcommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowSubcommandHelp.(cmd)
186 }
187 return ctx, nil
188 }
189 if cmd.OnUsageErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#OnUsageError. != nil {
190 err = cmd.OnUsageErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#OnUsageError.(ctx, cmd, err, cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil)
191 err = cmd.handleExitCoderscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#handleExitCoder().(ctx, err)
192 return ctx, err
193 }
194 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().().ErrWriterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ErrWriter., "Incorrect Usage: %s\n\n", err.Error())
195 if cmd.Suggestscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Suggest. {
196 if suggestion, err := cmd.suggestFlagFromErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#suggestFlagFromError().(err, ""); err == nil {
197 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().().ErrWriterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ErrWriter., "%s", suggestion)
198 }
199 }
200 if !cmd.hideHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#hideHelp().() {
201 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. == nil {
202 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running ShowRootCommandHelp")
203 if err := ShowRootCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowRootCommandHelp.(cmd); err != nil {
204 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("SILENTLY IGNORING ERROR running ShowRootCommandHelp %[1]v (cmd=%[2]q)", err, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
205 }
206 } else {
207 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running ShowSubcommandHelp for %[1]q", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
208 _ = ShowSubcommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowSubcommandHelp.(cmd)
209 }
210 }
211
212 return ctx, err
213 }
214
215 if cmd.checkHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#checkHelp().() {
216 ctx = contextscip-go gomod github.com/golang/go/src go1.22 context/.WithValuescip-go gomod github.com/golang/go/src go1.22 context/WithValue().(ctx, helpShownKeyscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpShownKey#{}, true)
217 return ctx, helpCommandActionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpCommandAction().(ctx, cmd)
218 } else {
219 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("no help is wanted (cmd=%[1]q)", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
220 }
221
222 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. == nil && !cmd.HideVersionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#HideVersion. && checkVersionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/checkVersion().(cmd) {
223 ShowVersionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowVersion().(cmd)
224 return ctx, nil
225 }
226
227 for _, flag := range cmd.allFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#allFlags().() {
228 cmd.setMultiValueParsingConfigscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setMultiValueParsingConfig().(flag)
229 isSet := flag.IsSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#IsSet.()
230 if err := flag.PostParsescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#PostParse.(); err != nil {
231 return ctx, err
232 }
233 // add env set flags here
234 if !isSet && flag.IsSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#IsSet.() {
235 cmd.setFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setFlags.[flag] = struct{}{}
236 }
237 }
238
239 if cmd.Afterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#After. != nil && !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. {
240 defer func() {
241 if ctx.Valuescip-go gomod github.com/golang/go/src go1.22 context/Context#Value().(helpShownKeyscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/helpShownKey#{}) != nil {
242 return
243 }
244 if err := cmd.Afterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#After.(ctx, cmd); err != nil {
245 err = cmd.handleExitCoderscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#handleExitCoder().(ctx, err)
246
247 if deferErr != nil {
248 deferErr = newMultiErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/newMultiError().(deferErr, err)
249 } else {
250 deferErr = err
251 }
252 }
253 }()
254 }
255
256 // Walk the parent chain to check mutually exclusive flag groups
257 // defined on ancestor commands, since persistent flags are inherited.
258 for pCmd := cmd; pCmd != nil; pCmd = pCmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. {
259 for _, grp := range pCmd.MutuallyExclusiveFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#MutuallyExclusiveFlags. {
260 if err := grp.checkscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#check().(cmd); err != nil {
261 if cmd.OnUsageErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#OnUsageError. != nil {
262 err = cmd.OnUsageErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#OnUsageError.(ctx, cmd, err, cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil)
263 } else {
264 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().().ErrWriterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ErrWriter., "Incorrect Usage: %s\n\n", err.Error())
265 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. == nil {
266 _ = ShowRootCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowRootCommandHelp.(cmd)
267 } else {
268 if err := 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.); err != nil {
269 _ = ShowSubcommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowSubcommandHelp.(cmd)
270 }
271 }
272 }
273 return ctx, err
274 }
275 }
276 }
277
278 var subCmd *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#
279 if cmd.parsedArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parsedArgs..Presentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#Present.() {
280 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("checking positional args %[1]q (cmd=%[2]q)", cmd.parsedArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parsedArgs., cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
281
282 name := cmd.parsedArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parsedArgs..Firstscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#First.()
283
284 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("using first positional argument as sub-command name=%[1]q (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
285
286 if cmd.SuggestCommandFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#SuggestCommandFunc. != nil && name != "--" {
287 name = cmd.SuggestCommandFuncscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#SuggestCommandFunc.(cmd.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands., name)
288 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("suggested command name=%1[q] (cmd=%[2]q)", name, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
289 }
290 subCmd = cmd.Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Command().(name)
291 if subCmd == nil {
292 hasDefault := cmd.DefaultCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#DefaultCommand. != ""
293
294 if hasDefault {
295 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("using default command=%[1]q (cmd=%[2]q)", cmd.DefaultCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#DefaultCommand., cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
296 }
297
298 if hasDefault {
299 argsWithDefault := cmd.argsWithDefaultCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#argsWithDefaultCommand().(cmd.parsedArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parsedArgs.)
300 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("using default command args=%[1]q (cmd=%[2]q)", argsWithDefault, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
301 subCmd = cmd.Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Command().(argsWithDefault.Firstscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Args#First.())
302 cmd.parsedArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parsedArgs. = argsWithDefault
303 }
304 }
305 } else if cmd.DefaultCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#DefaultCommand. != "" {
306 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("no positional args present; checking default command %[1]q (cmd=%[2]q)", cmd.DefaultCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#DefaultCommand., cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
307
308 if dc := cmd.Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Command().(cmd.DefaultCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#DefaultCommand.); dc != cmd {
309 subCmd = dc
310 }
311 }
312
313 // If a subcommand has been resolved, let it handle the remaining execution.
314 if subCmd != nil {
315 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running sub-command %[1]q with arguments %[2]q (cmd=%[3]q)", subCmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name., cmd.Argsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Args().(), cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
316
317 // It is important that we overwrite the ctx variable in the current
318 // function so any defer'd functions use the new context returned
319 // from the sub command.
320 ctx, err = subCmd.runscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#run().(ctx, 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.())
321 return ctx, err
322 }
323
324 // This code path is the innermost command execution. Here we actually
325 // perform the command action.
326 //
327 // First, resolve the chain of nested commands up to the parent.
328 cmdChain := commandChainscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandChain().(cmd)
329
330 // Run Before actions in order.
331 if ctx, err = runBeforescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/runBefore().(ctx, cmdChain); err != nil {
332 deferErr = err
333 return ctx, deferErr
334 }
335
336 // Run flag actions in order.
337 // These take a context, so this has to happen after Before actions.
338 for _, cmd := range cmdChain {
339 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("running flag actions (cmd=%[1]q)", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
340 if err := cmd.runFlagActionsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#runFlagActions().(ctx); err != nil {
341 deferErr = cmd.handleExitCoderscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#handleExitCoder().(ctx, err)
342 return ctx, deferErr
343 }
344 }
345
346 if err := cmd.checkAllRequiredFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#checkAllRequiredFlags().(); err != nil {
347 cmd.isInErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#isInError. = true
348 if cmd.OnUsageErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#OnUsageError. != nil {
349 err = cmd.OnUsageErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#OnUsageError.(ctx, cmd, err, cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil)
350 } else {
351 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().().ErrWriterscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ErrWriter., "Incorrect Usage: %s\n\n", err.Error())
352 if cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. == nil {
353 _ = ShowRootCommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowRootCommandHelp.(cmd)
354 } else {
355 if err := 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.); err != nil {
356 _ = ShowSubcommandHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ShowSubcommandHelp.(cmd)
357 }
358 }
359 }
360 return ctx, err
361 }
362
363 // Run the command action.
364 if len(cmd.Argumentsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Arguments.) > 0 {
365 rargs := 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.()
366 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("calling argparse with %[1]v", rargs)
367 for _, arg := range cmd.Argumentsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Arguments. {
368 var err error
369 rargs, err = arg.Parsescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Argument#Parse.(rargs)
370 if err != nil {
371 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("calling with %[1]v (cmd=%[2]q)", err, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
372 if cmd.OnUsageErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#OnUsageError. != nil {
373 err = cmd.OnUsageErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#OnUsageError.(ctx, cmd, err, cmd.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. != nil)
374 }
375 err = cmd.handleExitCoderscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#handleExitCoder().(ctx, err)
376 return ctx, err
377 }
378 }
379 cmd.parsedArgsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parsedArgs. = &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.: rargs}
380 }
381
382 if err := cmd.Actionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Action.(ctx, cmd); err != nil {
383 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("calling handleExitCoder with %[1]v (cmd=%[2]q)", err, cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name.)
384 deferErr = cmd.handleExitCoderscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#handleExitCoder().(ctx, err)
385 }
386
387 tracefscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/tracef().("returning deferErr (cmd=%[1]q) %[2]q", cmd.Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Name., deferErr)
388 return ctx, deferErr
389 }
390
391 func commandChainscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandChain().(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# {
392 var cmdChain []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#
393 for p := cmd; p != nil; p = p.parentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#parent. {
394 cmdChain = append(cmdChain, p)
395 }
396 slicesscip-go gomod github.com/golang/go/src go1.22 slices/.Reversescip-go gomod github.com/golang/go/src go1.22 slices/Reverse().(cmdChain)
397 return cmdChain
398 }
399
400 func runBeforescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/runBefore().(ctx contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, cmdChain []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) (contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, error) {
401 for _, cmd := range cmdChain {
402 if cmd.Beforescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Before. == nil {
403 continue
404 }
405 if bctx, err := cmd.Beforescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Before.(ctx, cmd); err != nil {
406 return ctx, cmd.handleExitCoderscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#handleExitCoder().(ctx, err)
407 } else if bctx != nil {
408 ctx = bctx
409 }
410 }
411 return ctx, nil
412 }