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

Function runSetCmd

pkg/cmd/settings/set/set.go:80–116  ·  view source on GitHub ↗
(opts *SetOptions)

Source from the content-addressed store, hash-verified

78}
79
80func runSetCmd(opts *SetOptions) error {
81 client, err := opts.SearchClient()
82 if err != nil {
83 return err
84 }
85
86 opts.IO.StartProgressIndicatorWithLabel(
87 fmt.Sprintf("Setting settings for index %s", opts.Index),
88 )
89
90 res, err := client.SetSettings(
91 client.NewApiSetSettingsRequest(opts.Index, &opts.Settings).
92 WithForwardToReplicas(opts.ForwardToReplicas),
93 )
94 if err != nil {
95 opts.IO.StopProgressIndicator()
96 return err
97 }
98
99 if opts.Wait {
100 opts.IO.UpdateProgressIndicatorLabel("Waiting for the task to complete")
101 _, err := client.WaitForTask(opts.Index, res.TaskID)
102 if err != nil {
103 opts.IO.StopProgressIndicator()
104 return err
105 }
106 }
107
108 opts.IO.StopProgressIndicator()
109
110 cs := opts.IO.ColorScheme()
111 if opts.IO.IsStdoutTTY() {
112 fmt.Fprintf(opts.IO.Out, "%s Set settings on %v\n", cs.SuccessIcon(), opts.Index)
113 }
114
115 return nil
116}

Callers 1

NewSetCmdFunction · 0.70

Calls 6

StopProgressIndicatorMethod · 0.80
ColorSchemeMethod · 0.80
IsStdoutTTYMethod · 0.80
SuccessIconMethod · 0.80

Tested by

no test coverage detected