(opts *CreateOptions)
| 81 | } |
| 82 | |
| 83 | func runCreateCmd(opts *CreateOptions) error { |
| 84 | if opts.DryRun { |
| 85 | summary := map[string]any{ |
| 86 | "action": "create_crawler", |
| 87 | "name": opts.Name, |
| 88 | "config": opts.config, |
| 89 | "dryRun": true, |
| 90 | } |
| 91 | |
| 92 | return cmdutil.PrintRunSummary( |
| 93 | opts.IO, |
| 94 | opts.PrintFlags, |
| 95 | summary, |
| 96 | fmt.Sprintf("Dry run: would create Crawler %s", opts.Name), |
| 97 | ) |
| 98 | } |
| 99 | |
| 100 | client, err := opts.CrawlerClient() |
| 101 | if err != nil { |
| 102 | return err |
| 103 | } |
| 104 | cs := opts.IO.ColorScheme() |
| 105 | |
| 106 | opts.IO.StartProgressIndicatorWithLabel("Creating crawler") |
| 107 | id, err := client.Create(opts.Name, opts.config) |
| 108 | opts.IO.StopProgressIndicator() |
| 109 | if err != nil { |
| 110 | return err |
| 111 | } |
| 112 | |
| 113 | if opts.IO.IsStdoutTTY() { |
| 114 | fmt.Fprintf( |
| 115 | opts.IO.Out, |
| 116 | "%s Crawler %s created: %s\n", |
| 117 | cs.SuccessIconWithColor(cs.Green), |
| 118 | cs.Bold(opts.Name), |
| 119 | cs.Bold(id), |
| 120 | ) |
| 121 | } |
| 122 | |
| 123 | return nil |
| 124 | } |
no test coverage detected