diff --git a/pkg/cmd/alias/delete/delete.go b/pkg/cmd/alias/delete/delete.go index a0ff1973b..f8ee065c4 100644 --- a/pkg/cmd/alias/delete/delete.go +++ b/pkg/cmd/alias/delete/delete.go @@ -62,8 +62,8 @@ func deleteRun(opts *DeleteOptions) error { } if opts.IO.IsStdoutTTY() { - redCheck := opts.IO.ColorScheme().Red("✓") - fmt.Fprintf(opts.IO.ErrOut, "%s Deleted alias %s; was %s\n", redCheck, opts.Name, expansion) + cs := opts.IO.ColorScheme() + fmt.Fprintf(opts.IO.ErrOut, "%s Deleted alias %s; was %s\n", cs.SuccessIconWithColor(cs.Red), opts.Name, expansion) } return nil diff --git a/pkg/cmd/gist/create/create.go b/pkg/cmd/gist/create/create.go index dd46b6edd..fe6fac748 100644 --- a/pkg/cmd/gist/create/create.go +++ b/pkg/cmd/gist/create/create.go @@ -140,7 +140,7 @@ func createRun(opts *CreateOptions) error { return fmt.Errorf("%s Failed to create gist: %w", cs.Red("X"), err) } - fmt.Fprintf(errOut, "%s %s\n", cs.SuccessIcon(), completionMessage) + fmt.Fprintf(errOut, "%s %s\n", cs.SuccessIconWithColor(cs.Green), completionMessage) if opts.WebMode { fmt.Fprintf(opts.IO.Out, "Opening %s in your browser.\n", utils.DisplayURL(gist.HTMLURL)) diff --git a/pkg/cmd/issue/close/close.go b/pkg/cmd/issue/close/close.go index a6aa04bc6..0a5355c21 100644 --- a/pkg/cmd/issue/close/close.go +++ b/pkg/cmd/issue/close/close.go @@ -75,7 +75,7 @@ func closeRun(opts *CloseOptions) error { return err } - fmt.Fprintf(opts.IO.ErrOut, "%s Closed issue #%d (%s)\n", cs.Red("✔"), issue.Number, issue.Title) + fmt.Fprintf(opts.IO.ErrOut, "%s Closed issue #%d (%s)\n", cs.SuccessIconWithColor(cs.Red), issue.Number, issue.Title) return nil } diff --git a/pkg/cmd/issue/reopen/reopen.go b/pkg/cmd/issue/reopen/reopen.go index e65e2eceb..b0bb784f3 100644 --- a/pkg/cmd/issue/reopen/reopen.go +++ b/pkg/cmd/issue/reopen/reopen.go @@ -75,7 +75,7 @@ func reopenRun(opts *ReopenOptions) error { return err } - fmt.Fprintf(opts.IO.ErrOut, "%s Reopened issue #%d (%s)\n", cs.SuccessIcon(), issue.Number, issue.Title) + fmt.Fprintf(opts.IO.ErrOut, "%s Reopened issue #%d (%s)\n", cs.SuccessIconWithColor(cs.Green), issue.Number, issue.Title) return nil } diff --git a/pkg/cmd/pr/close/close.go b/pkg/cmd/pr/close/close.go index 6b6cc8c9a..f4cc442c2 100644 --- a/pkg/cmd/pr/close/close.go +++ b/pkg/cmd/pr/close/close.go @@ -86,7 +86,7 @@ func closeRun(opts *CloseOptions) error { return fmt.Errorf("API call failed: %w", err) } - fmt.Fprintf(opts.IO.ErrOut, "%s Closed pull request #%d (%s)\n", cs.Red("✔"), pr.Number, pr.Title) + fmt.Fprintf(opts.IO.ErrOut, "%s Closed pull request #%d (%s)\n", cs.SuccessIconWithColor(cs.Red), pr.Number, pr.Title) crossRepoPR := pr.HeadRepositoryOwner.Login != baseRepo.RepoOwner() @@ -132,7 +132,7 @@ func closeRun(opts *CloseOptions) error { return err } } - fmt.Fprintf(opts.IO.ErrOut, "%s Deleted branch %s%s\n", cs.Red("✔"), cs.Cyan(pr.HeadRefName), branchSwitchString) + fmt.Fprintf(opts.IO.ErrOut, "%s Deleted branch %s%s\n", cs.SuccessIconWithColor(cs.Red), cs.Cyan(pr.HeadRefName), branchSwitchString) } return nil diff --git a/pkg/cmd/pr/merge/merge.go b/pkg/cmd/pr/merge/merge.go index b41fbc46b..6626c3bc1 100644 --- a/pkg/cmd/pr/merge/merge.go +++ b/pkg/cmd/pr/merge/merge.go @@ -180,7 +180,7 @@ func mergeRun(opts *MergeOptions) error { case api.PullRequestMergeMethodSquash: action = "Squashed and merged" } - fmt.Fprintf(opts.IO.ErrOut, "%s %s pull request #%d (%s)\n", cs.Magenta("✔"), action, pr.Number, pr.Title) + fmt.Fprintf(opts.IO.ErrOut, "%s %s pull request #%d (%s)\n", cs.SuccessIconWithColor(cs.Magenta), action, pr.Number, pr.Title) } } else if !opts.IsDeleteBranchIndicated && opts.InteractiveMode && !crossRepoPR { err := prompt.SurveyAskOne(&survey.Confirm{ @@ -243,7 +243,7 @@ func mergeRun(opts *MergeOptions) error { } if isTerminal { - fmt.Fprintf(opts.IO.ErrOut, "%s Deleted branch %s%s\n", cs.Red("✔"), cs.Cyan(pr.HeadRefName), branchSwitchString) + fmt.Fprintf(opts.IO.ErrOut, "%s Deleted branch %s%s\n", cs.SuccessIconWithColor(cs.Red), cs.Cyan(pr.HeadRefName), branchSwitchString) } return nil diff --git a/pkg/cmd/pr/merge/merge_test.go b/pkg/cmd/pr/merge/merge_test.go index bf45d68ea..0f97a945e 100644 --- a/pkg/cmd/pr/merge/merge_test.go +++ b/pkg/cmd/pr/merge/merge_test.go @@ -523,7 +523,7 @@ func TestPrMerge_alreadyMerged(t *testing.T) { } //nolint:staticcheck // prefer exact matchers over ExpectLines - test.ExpectLines(t, output.Stderr(), "✔ Deleted branch blueberries and switched to branch master") + test.ExpectLines(t, output.Stderr(), "✓ Deleted branch blueberries and switched to branch master") } func TestPrMerge_alreadyMerged_nonInteractive(t *testing.T) { diff --git a/pkg/cmd/pr/ready/ready.go b/pkg/cmd/pr/ready/ready.go index d160eccf4..003902963 100644 --- a/pkg/cmd/pr/ready/ready.go +++ b/pkg/cmd/pr/ready/ready.go @@ -88,7 +88,7 @@ func readyRun(opts *ReadyOptions) error { return fmt.Errorf("API call failed: %w", err) } - fmt.Fprintf(opts.IO.ErrOut, "%s Pull request #%d is marked as \"ready for review\"\n", cs.SuccessIcon(), pr.Number) + fmt.Fprintf(opts.IO.ErrOut, "%s Pull request #%d is marked as \"ready for review\"\n", cs.SuccessIconWithColor(cs.Green), pr.Number) return nil } diff --git a/pkg/cmd/pr/reopen/reopen.go b/pkg/cmd/pr/reopen/reopen.go index afbc1c37f..135e341fa 100644 --- a/pkg/cmd/pr/reopen/reopen.go +++ b/pkg/cmd/pr/reopen/reopen.go @@ -80,7 +80,7 @@ func reopenRun(opts *ReopenOptions) error { return fmt.Errorf("API call failed: %w", err) } - fmt.Fprintf(opts.IO.ErrOut, "%s Reopened pull request #%d (%s)\n", cs.SuccessIcon(), pr.Number, pr.Title) + fmt.Fprintf(opts.IO.ErrOut, "%s Reopened pull request #%d (%s)\n", cs.SuccessIconWithColor(cs.Green), pr.Number, pr.Title) return nil } diff --git a/pkg/cmd/release/delete/delete.go b/pkg/cmd/release/delete/delete.go index 0c78357c5..fde3fbcee 100644 --- a/pkg/cmd/release/delete/delete.go +++ b/pkg/cmd/release/delete/delete.go @@ -92,7 +92,7 @@ func deleteRun(opts *DeleteOptions) error { } iofmt := opts.IO.ColorScheme() - fmt.Fprintf(opts.IO.ErrOut, "%s Deleted release %s\n", iofmt.SuccessIcon(), release.TagName) + fmt.Fprintf(opts.IO.ErrOut, "%s Deleted release %s\n", iofmt.SuccessIconWithColor(iofmt.Red), release.TagName) if !release.IsDraft { fmt.Fprintf(opts.IO.ErrOut, "%s Note that the %s git tag still remains in the repository\n", iofmt.WarningIcon(), release.TagName) } diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index 6d8426cf1..bccd6f9a4 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -249,7 +249,7 @@ func createRun(opts *CreateOptions) error { isTTY := opts.IO.IsStdoutTTY() if isTTY { - fmt.Fprintf(stderr, "%s Created repository %s on GitHub\n", cs.SuccessIcon(), ghrepo.FullName(repo)) + fmt.Fprintf(stderr, "%s Created repository %s on GitHub\n", cs.SuccessIconWithColor(cs.Green), ghrepo.FullName(repo)) } else { fmt.Fprintln(stdout, repo.URL) } diff --git a/pkg/cmd/repo/fork/fork.go b/pkg/cmd/repo/fork/fork.go index e983976ef..e10e45431 100644 --- a/pkg/cmd/repo/fork/fork.go +++ b/pkg/cmd/repo/fork/fork.go @@ -177,7 +177,7 @@ func forkRun(opts *ForkOptions) error { } } else { if connectedToTerminal { - fmt.Fprintf(stderr, "%s Created fork %s\n", cs.SuccessIcon(), cs.Bold(ghrepo.FullName(forkedRepo))) + fmt.Fprintf(stderr, "%s Created fork %s\n", cs.SuccessIconWithColor(cs.Green), cs.Bold(ghrepo.FullName(forkedRepo))) } } diff --git a/pkg/cmd/secret/remove/remove.go b/pkg/cmd/secret/remove/remove.go index 000b71ae4..55ab08a67 100644 --- a/pkg/cmd/secret/remove/remove.go +++ b/pkg/cmd/secret/remove/remove.go @@ -80,14 +80,12 @@ func removeRun(opts *RemoveOptions) error { } if opts.IO.IsStdoutTTY() { - cs := opts.IO.ColorScheme() + target := orgName if orgName == "" { - fmt.Fprintf(opts.IO.Out, - "%s Removed secret %s from %s\n", cs.SuccessIcon(), opts.SecretName, ghrepo.FullName(baseRepo)) - } else { - fmt.Fprintf(opts.IO.Out, - "%s Removed secret %s from %s\n", cs.SuccessIcon(), opts.SecretName, orgName) + target = ghrepo.FullName(baseRepo) } + cs := opts.IO.ColorScheme() + fmt.Fprintf(opts.IO.Out, "%s Removed secret %s from %s\n", cs.SuccessIconWithColor(cs.Red), opts.SecretName, target) } return nil diff --git a/pkg/cmd/secret/set/set.go b/pkg/cmd/secret/set/set.go index 1a05d93cc..4c4c20908 100644 --- a/pkg/cmd/secret/set/set.go +++ b/pkg/cmd/secret/set/set.go @@ -161,13 +161,12 @@ func setRun(opts *SetOptions) error { } if opts.IO.IsStdoutTTY() { - cs := opts.IO.ColorScheme() - + target := orgName if orgName == "" { - fmt.Fprintf(opts.IO.Out, "%s Set secret %s for %s\n", cs.SuccessIcon(), opts.SecretName, ghrepo.FullName(baseRepo)) - } else { - fmt.Fprintf(opts.IO.Out, "%s Set secret %s for %s\n", cs.SuccessIcon(), opts.SecretName, orgName) + target = ghrepo.FullName(baseRepo) } + cs := opts.IO.ColorScheme() + fmt.Fprintf(opts.IO.Out, "%s Set secret %s for %s\n", cs.SuccessIconWithColor(cs.Green), opts.SecretName, target) } return nil diff --git a/pkg/iostreams/color.go b/pkg/iostreams/color.go index 972caab3d..46cfc3a3c 100644 --- a/pkg/iostreams/color.go +++ b/pkg/iostreams/color.go @@ -123,7 +123,11 @@ func (c *ColorScheme) Blue(t string) string { } func (c *ColorScheme) SuccessIcon() string { - return c.Green("✓") + return c.SuccessIconWithColor(c.Green) +} + +func (c *ColorScheme) SuccessIconWithColor(colo func(string) string) string { + return colo("✓") } func (c *ColorScheme) WarningIcon() string {