MCPcopy Create free account
hub / github.com/algolia/cli / runPauseCmd

Function runPauseCmd

pkg/cmd/crawler/pause/pause.go:66–109  ·  view source on GitHub ↗
(opts *PauseOptions)

Source from the content-addressed store, hash-verified

64}
65
66func 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}

Callers 1

NewPauseCmdFunction · 0.85

Calls 10

PrintRunSummaryFunction · 0.92
PluralizeFunction · 0.92
ColorSchemeMethod · 0.80
ReindexMethod · 0.80
StopProgressIndicatorMethod · 0.80
BoldMethod · 0.80
IsStdoutTTYMethod · 0.80
SuccessIconWithColorMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected