()
| 125 | } |
| 126 | |
| 127 | func (cli *cliItem) newInstallCmd() *cobra.Command { |
| 128 | var ( |
| 129 | interactive bool |
| 130 | dryRun bool |
| 131 | downloadOnly bool |
| 132 | force bool |
| 133 | ignoreError bool |
| 134 | ) |
| 135 | |
| 136 | cmd := &cobra.Command{ |
| 137 | Use: cmp.Or(cli.installHelp.use, "install [item]..."), |
| 138 | Short: cmp.Or(cli.installHelp.short, "Install given "+cli.oneOrMore), |
| 139 | Long: cmp.Or(cli.installHelp.long, fmt.Sprintf("Fetch and install one or more %s from the hub", cli.name)), |
| 140 | Example: cli.installHelp.example, |
| 141 | Args: args.MinimumNArgs(1), |
| 142 | DisableAutoGenTag: true, |
| 143 | ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 144 | return compAllItems(cli.name, args, toComplete, cli.cfg) |
| 145 | }, |
| 146 | RunE: func(cmd *cobra.Command, args []string) error { |
| 147 | return cli.install(cmd.Context(), args, interactive, dryRun, downloadOnly, force, ignoreError) |
| 148 | }, |
| 149 | } |
| 150 | |
| 151 | flags := cmd.Flags() |
| 152 | flags.BoolVarP(&interactive, "interactive", "i", false, "Ask for confirmation before proceeding") |
| 153 | flags.BoolVar(&dryRun, "dry-run", false, "Don't install or remove anything; print the execution plan") |
| 154 | flags.BoolVarP(&downloadOnly, "download-only", "d", false, "Only download packages, don't enable") |
| 155 | flags.BoolVar(&force, "force", false, "Force install: overwrite tainted and outdated files") |
| 156 | flags.BoolVar(&ignoreError, "ignore", false, "Ignore errors when installing multiple "+cli.name) |
| 157 | cmd.MarkFlagsMutuallyExclusive("interactive", "dry-run") |
| 158 | |
| 159 | return cmd |
| 160 | } |
no test coverage detected