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

Method newInteractiveCmd

cmd/crowdsec-cli/clisetup/interactive.go:15–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13)
14
15func (cli *cliSetup) newInteractiveCmd() *cobra.Command {
16 df := detectFlags{}
17 af := acquisitionFlags{}
18
19 var dryRun bool
20
21 cmd := &cobra.Command{
22 Use: "interactive",
23 Short: "Interactive setup",
24 Long: "Detect services and generate configuration, with user prompts",
25 Example: `# Detect running services, install the appropriate collections and acquisition configuration.
26# prompt the user for confirmation at each step
27cscli setup interactive
28
29# write acquisition files to a specific directory
30cscli setup interactive --acquis-dir /path/to/acquis.d
31
32# use a different set of detection rules
33cscli setup interactive --detect-config /path/to/detact.yaml
34`,
35 DisableAutoGenTag: true,
36 Args: args.NoArgs,
37 RunE: func(cmd *cobra.Command, _ []string) error {
38 detectConfig, _, err := df.detectConfig()
39 if err != nil {
40 return err
41 }
42
43 logger := logrus.StandardLogger()
44
45 err = cli.wizard(cmd.Context(), detectConfig, df.toDetectOptions(logger), af.acquisDir, true, dryRun, logger)
46 if errors.Is(err, hubops.ErrUserCanceled) {
47 fmt.Fprintln(os.Stdout, err.Error())
48 fmt.Fprintln(os.Stdout, "You can always run 'cscli setup' later.")
49 return nil
50 }
51
52 return err
53 },
54 }
55
56 df.bind(cmd)
57 af.bind(cmd)
58
59 flags := cmd.Flags()
60 flags.BoolVar(&dryRun, "dry-run", false, "simulate the installation without making any changes")
61
62 return cmd
63}

Callers 1

NewCommandMethod · 0.95

Calls 7

detectConfigMethod · 0.95
wizardMethod · 0.95
toDetectOptionsMethod · 0.95
bindMethod · 0.95
bindMethod · 0.95
StandardLoggerMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected