| 74 | } |
| 75 | |
| 76 | func cloneRun(opts *cloneOptions) error { |
| 77 | httpClient, err := opts.HttpClient() |
| 78 | if err != nil { |
| 79 | return err |
| 80 | } |
| 81 | |
| 82 | baseRepo, err := opts.BaseRepo() |
| 83 | if err != nil { |
| 84 | return err |
| 85 | } |
| 86 | |
| 87 | opts.IO.StartProgressIndicator() |
| 88 | successCount, totalCount, err := cloneLabels(httpClient, baseRepo, opts) |
| 89 | opts.IO.StopProgressIndicator() |
| 90 | if err != nil { |
| 91 | return err |
| 92 | } |
| 93 | |
| 94 | if opts.IO.IsStdoutTTY() { |
| 95 | cs := opts.IO.ColorScheme() |
| 96 | pluralize := func(num int) string { |
| 97 | return text.Pluralize(num, "label") |
| 98 | } |
| 99 | |
| 100 | successCount := int(successCount) |
| 101 | switch { |
| 102 | case successCount == totalCount: |
| 103 | fmt.Fprintf(opts.IO.Out, "%s Cloned %s from %s to %s\n", cs.SuccessIcon(), pluralize(successCount), ghrepo.FullName(opts.SourceRepo), ghrepo.FullName(baseRepo)) |
| 104 | default: |
| 105 | fmt.Fprintf(opts.IO.Out, "%s Cloned %s of %d from %s to %s\n", cs.WarningIcon(), pluralize(successCount), totalCount, ghrepo.FullName(opts.SourceRepo), ghrepo.FullName(baseRepo)) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | return nil |
| 110 | } |
| 111 | |
| 112 | func cloneLabels(client *http.Client, destination ghrepo.Interface, opts *cloneOptions) (successCount uint32, totalCount int, err error) { |
| 113 | successCount = 0 |