MCPcopy Create free account
hub / github.com/openclaw/gogcli / executeWithRuntime

Function executeWithRuntime

internal/cmd/root.go:121–311  ·  view source on GitHub ↗
(args []string, runtime *app.Runtime)

Source from the content-addressed store, hash-verified

119}
120
121func executeWithRuntime(args []string, runtime *app.Runtime) (err error) {
122 runtime = normalizedRuntime(runtime)
123 runtimeIO := runtime.IO
124
125 if len(args) == 0 {
126 args = []string{"--help"}
127 }
128 args = rewriteHelpArgs(args)
129
130 home, homeProvided := preScanHomeArg(args)
131 if bindErr := bindRuntimeLayoutResolver(runtime, home); bindErr != nil {
132 return reportEarlyError(runtimeIO.Err, newUsageError(bindErr))
133 }
134 if homeProvided {
135 if validateErr := runtime.LayoutResolver.ValidateHomeOverride(); validateErr != nil {
136 return reportEarlyError(runtimeIO.Err, newUsageError(validateErr))
137 }
138 }
139
140 parser, cli, err := newParserWithWriters(helpDescription(runtime), runtimeIO.Out, runtimeIO.Err)
141 if err != nil {
142 return reportEarlyError(runtimeIO.Err, err)
143 }
144 args = rewriteDocsCellUpdateContentArgs(parser.Model, args)
145 args = rewriteDesirePathArgs(parser.Model, args)
146
147 defer func() {
148 if r := recover(); r != nil {
149 if ep, ok := r.(exitPanic); ok {
150 if ep.code == 0 {
151 err = nil
152 return
153 }
154 err = &ExitError{Code: ep.code, Err: errors.New("exited")}
155 return
156 }
157 panic(r)
158 }
159 }()
160
161 kctx, err := parser.Parse(args)
162 if err != nil {
163 return reportEarlyError(runtimeIO.Err, wrapParseError(err))
164 }
165 cli.diagnostics = runtimeIO.Err
166 cli.authOperations = runtime.Auth
167 cli.authMode = googleapi.ParseAuthMode(os.Getenv("GOG_AUTH_MODE"))
168 applyExplicitOutputModePrecedence(kctx, &cli.RootFlags)
169
170 if err = enforceBakedSafetyProfile(kctx); err != nil {
171 return reportEarlyError(runtimeIO.Err, err)
172 }
173 if err = enforceEnabledCommands(kctx, cli.EnableCommands, cli.EnableCommandsExact); err != nil {
174 return reportEarlyError(runtimeIO.Err, err)
175 }
176 if err = enforceDisabledCommands(kctx, cli.DisableCommands); err != nil {
177 return reportEarlyError(runtimeIO.Err, err)
178 }

Calls 15

ParseAuthModeFunction · 0.92
FromFlagsFunction · 0.92
WithRuntimeFunction · 0.92
WithReadOnlyFunction · 0.92
WithAuthDependenciesFunction · 0.92
NewFactoryFunction · 0.92
WithCredentialsReaderFunction · 0.92
WithSecretsStoreOpenerFunction · 0.92
WithClientResolverFunction · 0.92
WithModeFunction · 0.92
WithJSONTransformFunction · 0.92