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

Method providerRemoveCommand

internal/cli/provider_cmd.go:431–466  ·  view source on GitHub ↗
(state *globalState)

Source from the content-addressed store, hash-verified

429}
430
431func (a *App) providerRemoveCommand(state *globalState) *cobra.Command {
432 var yes bool
433 cmd := &cobra.Command{
434 Use: "remove NAME",
435 Aliases: []string{"rm", "delete"},
436 Short: "Remove a provider",
437 Args: cobra.ExactArgs(1),
438 RunE: func(cmd *cobra.Command, args []string) error {
439 name := args[0]
440 if _, err := providerAPI(state).Show(context.Background(), name); err != nil {
441 return fmt.Errorf("provider %q not found", name)
442 }
443 if !yes {
444 // Non-interactive contexts (no TTY) must opt out via
445 // --yes so scripts don't hang on stdin. We bail with a
446 // clear error rather than silently skipping.
447 if !inIsTTY(cmd.InOrStdin()) {
448 return fmt.Errorf("remove requires --yes when stdin is not a TTY")
449 }
450 fmt.Fprintf(cmd.OutOrStdout(), "Remove provider %q? [y/N]: ", name)
451 answer := readLine(cmd.InOrStdin())
452 if !strings.EqualFold(strings.TrimSpace(answer), "y") {
453 fmt.Fprintln(cmd.OutOrStdout(), "Aborted.")
454 return nil
455 }
456 }
457 if _, err := providerAPI(state).Remove(context.Background(), name); err != nil {
458 return err
459 }
460 fmt.Fprintf(cmd.OutOrStdout(), "Removed provider %q\n", name)
461 return nil
462 },
463 }
464 cmd.Flags().BoolVarP(&yes, "yes", "y", false, "Do not prompt for confirmation")
465 return cmd
466}
467
468func (a *App) providerEnableCommand(state *globalState) *cobra.Command {
469 return &cobra.Command{

Callers 1

providerCommandMethod · 0.95

Calls 5

providerAPIFunction · 0.85
inIsTTYFunction · 0.85
readLineFunction · 0.85
ShowMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected