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

Method configUnsetCommand

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

Source from the content-addressed store, hash-verified

216}
217
218func (a *App) configUnsetCommand(state *globalState) *cobra.Command {
219 var app string
220 var scope string
221 cmd := &cobra.Command{
222 Use: "unset KEY",
223 Short: "Unset a configuration key",
224 Args: cobra.ExactArgs(1),
225 RunE: func(cmd *cobra.Command, args []string) error {
226 out := cmd.OutOrStdout()
227 key := args[0]
228 if app == "" && state.configPath != "" {
229 if err := legacyUnsetConfig(state.configPath, key); err != nil {
230 return err
231 }
232 fmt.Fprintf(out, "Removed %s\n", key)
233 return nil
234 }
235 editor := app
236 if editor == "" {
237 return fmt.Errorf("--app is required (no --config supplied)")
238 }
239 tool, ok := editorconfig.DefaultRegistry().Get(editor)
240 if !ok {
241 return fmt.Errorf("Unknown app: %s", editor)
242 }
243 found, _, err := tool.Unset(scopeOrDefault(scope), key)
244 if err != nil {
245 return err
246 }
247 if !found {
248 fmt.Fprintf(out, "Key not found: %s\n", key)
249 return nil
250 }
251 fmt.Fprintf(out, "Unset %s from %s scope\n", key, scopeOrDefault(scope))
252 return nil
253 },
254 }
255 cmd.Flags().StringVarP(&app, "app", "a", "", "Editor to unset configuration for")
256 cmd.Flags().StringVarP(&scope, "scope", "s", "user", "Configuration scope (user|project)")
257 return cmd
258}
259
260func scopeOrDefault(scope string) editorconfig.Scope {
261 if scope == "project" {

Callers 1

configCommandMethod · 0.95

Calls 5

DefaultRegistryFunction · 0.92
legacyUnsetConfigFunction · 0.85
scopeOrDefaultFunction · 0.85
UnsetMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected