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

Function runCreateCmd

pkg/cmd/crawler/create/create.go:83–124  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

81}
82
83func 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}

Callers 1

NewCreateCmdFunction · 0.70

Calls 8

PrintRunSummaryFunction · 0.92
ColorSchemeMethod · 0.80
CreateMethod · 0.80
StopProgressIndicatorMethod · 0.80
IsStdoutTTYMethod · 0.80
SuccessIconWithColorMethod · 0.80
BoldMethod · 0.80

Tested by

no test coverage detected