MCPcopy
hub / github.com/cli/cli / editRun

Function editRun

pkg/cmd/label/edit.go:75–104  ·  view source on GitHub ↗
(opts *editOptions)

Source from the content-addressed store, hash-verified

73}
74
75func editRun(opts *editOptions) error {
76 httpClient, err := opts.HttpClient()
77 if err != nil {
78 return err
79 }
80 apiClient := api.NewClientFromHTTP(httpClient)
81
82 baseRepo, err := opts.BaseRepo()
83 if err != nil {
84 return err
85 }
86
87 opts.IO.StartProgressIndicator()
88 err = updateLabel(apiClient, baseRepo, opts)
89 opts.IO.StopProgressIndicator()
90 if err != nil {
91 if errors.Is(err, errLabelAlreadyExists) {
92 return fmt.Errorf("label with name %q already exists", opts.NewName)
93 }
94 return err
95 }
96
97 if opts.IO.IsStdoutTTY() {
98 cs := opts.IO.ColorScheme()
99 successMsg := fmt.Sprintf("%s Label %q updated in %s\n", cs.SuccessIcon(), opts.Name, ghrepo.FullName(baseRepo))
100 fmt.Fprint(opts.IO.Out, successMsg)
101 }
102
103 return nil
104}

Callers 2

TestEditRunFunction · 0.70
newCmdEditFunction · 0.70

Calls 10

NewClientFromHTTPFunction · 0.92
FullNameFunction · 0.92
updateLabelFunction · 0.85
IsStdoutTTYMethod · 0.80
ColorSchemeMethod · 0.80
SuccessIconMethod · 0.80
BaseRepoMethod · 0.65
StopProgressIndicatorMethod · 0.65
ErrorfMethod · 0.65

Tested by 1

TestEditRunFunction · 0.56