runUninstallCommandE handles the uninstall subcommand execution
(cmd *cobra.Command, args []string)
| 39 | |
| 40 | // runUninstallCommandE handles the uninstall subcommand execution |
| 41 | func runUninstallCommandE(cmd *cobra.Command, args []string) error { |
| 42 | slog.Debug("uninstall command started", "args", args) |
| 43 | |
| 44 | // Get and validate scope flag |
| 45 | scopeStr, err := cmd.Flags().GetString("scope") |
| 46 | if err != nil { |
| 47 | return fmt.Errorf("failed to get scope flag: %w", err) |
| 48 | } |
| 49 | |
| 50 | normalizedScope, err := install.NormalizeScope(scopeStr) |
| 51 | if err != nil { |
| 52 | return err |
| 53 | } |
| 54 | scope := InstallScope(normalizedScope) |
| 55 | |
| 56 | // Get and validate agent flag |
| 57 | agentStr, err := cmd.Flags().GetString("agent") |
| 58 | if err != nil { |
| 59 | return fmt.Errorf("failed to get agent flag: %w", err) |
| 60 | } |
| 61 | agent, err := install.ParseAgent(agentStr) |
| 62 | if err != nil { |
| 63 | return err |
| 64 | } |
| 65 | |
| 66 | // Get dry-run flag |
| 67 | dryRun, err := cmd.Flags().GetBool("dry-run") |
| 68 | if err != nil { |
| 69 | return fmt.Errorf("failed to get dry-run flag: %w", err) |
| 70 | } |
| 71 | |
| 72 | // Get quiet flag |
| 73 | quiet, err := cmd.Flags().GetBool("quiet") |
| 74 | if err != nil { |
| 75 | return fmt.Errorf("failed to get quiet flag: %w", err) |
| 76 | } |
| 77 | |
| 78 | // Get print flag |
| 79 | print, err := cmd.Flags().GetBool("print") |
| 80 | if err != nil { |
| 81 | return fmt.Errorf("failed to get print flag: %w", err) |
| 82 | } |
| 83 | |
| 84 | slog.Info("uninstall command executing", "scope", scope, "agent", agent, "dry_run", dryRun, "quiet", quiet, "print", print) |
| 85 | |
| 86 | targets, err := install.ResolveAgentTargets(agent, scope.String()) |
| 87 | if err != nil { |
| 88 | return err |
| 89 | } |
| 90 | |
| 91 | slog.Debug("resolved uninstall targets", "scope", scope, "agent", agent, "count", len(targets)) |
| 92 | |
| 93 | // Handle print flag - shows what hooks would be removed |
| 94 | if print { |
| 95 | return handlePrintUninstall(cmd, scope, targets, dryRun, quiet) |
| 96 | } |
| 97 | |
| 98 | // Handle dry-run mode - show what would be done without making changes |
nothing calls this directly
no test coverage detected