| 73 | } |
| 74 | |
| 75 | func 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 | } |