()
| 13 | ) |
| 14 | |
| 15 | func (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 |
| 27 | cscli setup interactive |
| 28 | |
| 29 | # write acquisition files to a specific directory |
| 30 | cscli setup interactive --acquis-dir /path/to/acquis.d |
| 31 | |
| 32 | # use a different set of detection rules |
| 33 | cscli 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 | } |
no test coverage detected