()
| 119 | } |
| 120 | |
| 121 | func (cli *cliItem) newRemoveCmd() *cobra.Command { |
| 122 | var ( |
| 123 | interactive bool |
| 124 | dryRun bool |
| 125 | purge bool |
| 126 | force bool |
| 127 | all bool |
| 128 | ) |
| 129 | |
| 130 | cmd := &cobra.Command{ |
| 131 | Use: cmp.Or(cli.removeHelp.use, "remove [item]..."), |
| 132 | Short: cmp.Or(cli.removeHelp.short, "Remove given "+cli.oneOrMore), |
| 133 | Long: cmp.Or(cli.removeHelp.long, "Remove one or more "+cli.name), |
| 134 | Example: cli.removeHelp.example, |
| 135 | Aliases: []string{"delete"}, |
| 136 | DisableAutoGenTag: true, |
| 137 | ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 138 | return compInstalledItems(cli.name, args, toComplete, cli.cfg) |
| 139 | }, |
| 140 | RunE: func(cmd *cobra.Command, args []string) error { |
| 141 | if len(args) > 0 && all { |
| 142 | return errors.New("can't specify items and '--all' at the same time") |
| 143 | } |
| 144 | |
| 145 | return cli.remove(cmd.Context(), args, interactive, dryRun, purge, force, all) |
| 146 | }, |
| 147 | } |
| 148 | |
| 149 | flags := cmd.Flags() |
| 150 | flags.BoolVarP(&interactive, "interactive", "i", false, "Ask for confirmation before proceeding") |
| 151 | flags.BoolVar(&dryRun, "dry-run", false, "Don't install or remove anything; print the execution plan") |
| 152 | flags.BoolVar(&purge, "purge", false, "Delete source file too") |
| 153 | flags.BoolVar(&force, "force", false, "Force remove: remove tainted and outdated files") |
| 154 | flags.BoolVar(&all, "all", false, "Remove all the "+cli.name) |
| 155 | cmd.MarkFlagsMutuallyExclusive("interactive", "dry-run") |
| 156 | |
| 157 | return cmd |
| 158 | } |
no test coverage detected