============================================================================ uninstall — remove from code agent(s) ============================================================================
(kind entities.Kind)
| 2095 | // ============================================================================ |
| 2096 | |
| 2097 | func entityUninstallCommand(kind entities.Kind) *cobra.Command { |
| 2098 | var ( |
| 2099 | app string |
| 2100 | all bool |
| 2101 | ) |
| 2102 | cmd := &cobra.Command{ |
| 2103 | Use: "uninstall [NAME...]", |
| 2104 | Aliases: []string{"rm", "remove"}, |
| 2105 | Short: "Uninstall " + string(kind) + "(s) from a code agent", |
| 2106 | Long: "Remove installed " + string(kind) + `(s) from a target code agent. |
| 2107 | |
| 2108 | When --app is omitted in an interactive terminal, you will be prompted |
| 2109 | to select target agent(s). |
| 2110 | |
| 2111 | Supported agents: ` + strings.Join(entities.SupportedApps(kind), ", ") + `. |
| 2112 | |
| 2113 | Use --all to uninstall every installed item from the selected agent(s).`, |
| 2114 | Example: " cam " + string(kind) + " uninstall my-skill --app claude\n" + |
| 2115 | " cam " + string(kind) + " uninstall --all --app claude\n" + |
| 2116 | " cam " + string(kind) + " uninstall skill-a skill-b", |
| 2117 | Args: cobra.ArbitraryArgs, |
| 2118 | RunE: func(cmd *cobra.Command, args []string) error { |
| 2119 | out := cmd.OutOrStdout() |
| 2120 | |
| 2121 | // Resolve target app(s). |
| 2122 | var apps []string |
| 2123 | if app != "" { |
| 2124 | apps = []string{app} |
| 2125 | } else if isInteractive(cmd.InOrStdin()) { |
| 2126 | picked, err := promptSelectApp(kind) |
| 2127 | if err != nil { |
| 2128 | return err |
| 2129 | } |
| 2130 | apps = picked |
| 2131 | } else { |
| 2132 | return fmt.Errorf("--app is required (one of: %s)", strings.Join(entities.SupportedApps(kind), ", ")) |
| 2133 | } |
| 2134 | |
| 2135 | if !all && len(args) == 0 { |
| 2136 | // Interactive: list what's installed and let user pick. |
| 2137 | if isInteractive(cmd.InOrStdin()) { |
| 2138 | return interactiveUninstall(kind, apps, out) |
| 2139 | } |
| 2140 | return fmt.Errorf("NAME is required (or use --all)") |
| 2141 | } |
| 2142 | |
| 2143 | for _, a := range apps { |
| 2144 | if all { |
| 2145 | uninstallAllFromApp(kind, a, out) |
| 2146 | } else { |
| 2147 | for _, name := range args { |
| 2148 | uninstallOneFromApp(kind, a, name, out) |
| 2149 | } |
| 2150 | } |
| 2151 | } |
| 2152 | return nil |
| 2153 | }, |
| 2154 | } |
no test coverage detected