MCPcopy
hub / github.com/crowdsecurity/crowdsec / newInstallCmd

Method newInstallCmd

cmd/crowdsec-cli/cliitem/cmdinstall.go:127–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125}
126
127func (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}

Callers 1

NewCommandMethod · 0.95

Calls 3

installMethod · 0.95
MinimumNArgsFunction · 0.92
compAllItemsFunction · 0.85

Tested by

no test coverage detected