(opts *PauseOptions)
| 64 | } |
| 65 | |
| 66 | func runPauseCmd(opts *PauseOptions) error { |
| 67 | if opts.DryRun { |
| 68 | summary := map[string]any{ |
| 69 | "action": "pause_crawlers", |
| 70 | "ids": opts.IDs, |
| 71 | "dryRun": true, |
| 72 | } |
| 73 | |
| 74 | return cmdutil.PrintRunSummary( |
| 75 | opts.IO, |
| 76 | opts.PrintFlags, |
| 77 | summary, |
| 78 | fmt.Sprintf("Dry run: would pause %s", utils.Pluralize(len(opts.IDs), "crawler")), |
| 79 | ) |
| 80 | } |
| 81 | |
| 82 | client, err := opts.CrawlerClient() |
| 83 | if err != nil { |
| 84 | return err |
| 85 | } |
| 86 | cs := opts.IO.ColorScheme() |
| 87 | |
| 88 | opts.IO.StartProgressIndicatorWithLabel( |
| 89 | fmt.Sprintf("Pausing %s", utils.Pluralize(len(opts.IDs), "crawler")), |
| 90 | ) |
| 91 | for _, id := range opts.IDs { |
| 92 | if _, err := client.Reindex(id); err != nil { |
| 93 | opts.IO.StopProgressIndicator() |
| 94 | return fmt.Errorf("cannot pause crawler %s: %w", cs.Bold(id), err) |
| 95 | } |
| 96 | } |
| 97 | opts.IO.StopProgressIndicator() |
| 98 | |
| 99 | if opts.IO.IsStdoutTTY() { |
| 100 | fmt.Fprintf( |
| 101 | opts.IO.Out, |
| 102 | "%s %s\n", |
| 103 | cs.SuccessIconWithColor(cs.Green), |
| 104 | fmt.Sprintf("Successfully paused %s", utils.Pluralize(len(opts.IDs), "crawler")), |
| 105 | ) |
| 106 | } |
| 107 | |
| 108 | return nil |
| 109 | } |
no test coverage detected