MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / configSetCommand

Method configSetCommand

internal/cli/config_cmd.go:174–216  ·  view source on GitHub ↗
(state *globalState)

Source from the content-addressed store, hash-verified

172}
173
174func (a *App) configSetCommand(state *globalState) *cobra.Command {
175 var app string
176 var scope string
177 cmd := &cobra.Command{
178 Use: "set KEY[=VALUE] [VALUE]",
179 Short: "Set a configuration key",
180 Args: cobra.RangeArgs(1, 2),
181 RunE: func(cmd *cobra.Command, args []string) error {
182 out := cmd.OutOrStdout()
183 key, value, ok := splitKeyValue(args)
184 if !ok {
185 return fmt.Errorf("expected KEY=VALUE or KEY VALUE")
186 }
187 // Legacy CAM-config mode: when --config is set and --app is not.
188 if app == "" && state.configPath != "" {
189 if err := legacyApplyValue(state.configPath, key, value); err != nil {
190 return err
191 }
192 fmt.Fprintf(out, "Updated %s\n", key)
193 return nil
194 }
195 editor := app
196 if editor == "" {
197 return fmt.Errorf("--app is required (no --config supplied)")
198 }
199 tool, ok := editorconfig.DefaultRegistry().Get(editor)
200 if !ok {
201 return fmt.Errorf("Unknown app: %s", editor)
202 }
203 coerced := editorconfig.ParseScalar(value)
204 savedPath, err := tool.Set(scopeOrDefault(scope), key, coerced)
205 if err != nil {
206 return err
207 }
208 fmt.Fprintf(out, "Set %s = %v (%s scope)\n", key, coerced, scopeOrDefault(scope))
209 fmt.Fprintf(out, " Config: %s\n", savedPath)
210 return nil
211 },
212 }
213 cmd.Flags().StringVarP(&app, "app", "a", "", "Editor to set configuration for")
214 cmd.Flags().StringVarP(&scope, "scope", "s", "user", "Configuration scope (user|project)")
215 return cmd
216}
217
218func (a *App) configUnsetCommand(state *globalState) *cobra.Command {
219 var app string

Callers 1

configCommandMethod · 0.95

Calls 7

DefaultRegistryFunction · 0.92
ParseScalarFunction · 0.92
splitKeyValueFunction · 0.85
legacyApplyValueFunction · 0.85
scopeOrDefaultFunction · 0.85
SetMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected