From 7325944040b16eb71fb89a85f93dc50b2ba68be2 Mon Sep 17 00:00:00 2001 From: Michael Hoffman Date: Sun, 2 Feb 2025 20:31:12 -0500 Subject: [PATCH] More consistency --- pkg/cmd/repo/autolink/create/create.go | 2 +- pkg/cmd/repo/autolink/delete/delete_test.go | 2 +- pkg/cmd/repo/autolink/list/list.go | 16 ++++++++-------- pkg/cmd/repo/autolink/view/view.go | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/cmd/repo/autolink/create/create.go b/pkg/cmd/repo/autolink/create/create.go index aad71a941..f06ad5cf9 100644 --- a/pkg/cmd/repo/autolink/create/create.go +++ b/pkg/cmd/repo/autolink/create/create.go @@ -112,7 +112,7 @@ func createRun(opts *createOptions) error { "%s Created repository autolink %s on %s\n", cs.SuccessIconWithColor(cs.Green), cs.Cyanf("%d", autolink.ID), - ghrepo.FullName(repo)) + cs.Bold(ghrepo.FullName(repo))) return nil } diff --git a/pkg/cmd/repo/autolink/delete/delete_test.go b/pkg/cmd/repo/autolink/delete/delete_test.go index 6dee277f8..99233fb1e 100644 --- a/pkg/cmd/repo/autolink/delete/delete_test.go +++ b/pkg/cmd/repo/autolink/delete/delete_test.go @@ -133,7 +133,7 @@ func TestDeleteRun(t *testing.T) { return nil } }, - wantStdout: "Autolink 123 has key prefix TICKET-.✓Autolink 123 deleted from OWNER/REPO\n", + wantStdout: "Autolink 123 has key prefix TICKET-.✓ Autolink 123 deleted from OWNER/REPO\n", }, { name: "delete with confirm flag", diff --git a/pkg/cmd/repo/autolink/list/list.go b/pkg/cmd/repo/autolink/list/list.go index 402479c44..7b10d558f 100644 --- a/pkg/cmd/repo/autolink/list/list.go +++ b/pkg/cmd/repo/autolink/list/list.go @@ -89,8 +89,14 @@ func listRun(opts *listOptions) error { return err } + cs := opts.IO.ColorScheme() + if len(autolinks) == 0 { - return cmdutil.NewNoResultsError(fmt.Sprintf("no autolinks found in %s", ghrepo.FullName(repo))) + return cmdutil.NewNoResultsError( + fmt.Sprintf( + "no autolinks found in %s", + cs.Bold(ghrepo.FullName(repo))), + ) } if opts.Exporter != nil { @@ -98,14 +104,12 @@ func listRun(opts *listOptions) error { } if opts.IO.IsStdoutTTY() { - title := listHeader(ghrepo.FullName(repo), len(autolinks)) + title := fmt.Sprintf("Showing %s in %s", text.Pluralize(len(autolinks), "autolink reference"), cs.Bold(ghrepo.FullName(repo))) fmt.Fprintf(opts.IO.Out, "\n%s\n\n", title) } tp := tableprinter.New(opts.IO, tableprinter.WithHeader("ID", "KEY PREFIX", "URL TEMPLATE", "ALPHANUMERIC")) - cs := opts.IO.ColorScheme() - for _, autolink := range autolinks { tp.AddField(cs.Cyanf("%d", autolink.ID)) tp.AddField(autolink.KeyPrefix) @@ -116,7 +120,3 @@ func listRun(opts *listOptions) error { return tp.Render() } - -func listHeader(repoName string, count int) string { - return fmt.Sprintf("Showing %s in %s", text.Pluralize(count, "autolink reference"), repoName) -} diff --git a/pkg/cmd/repo/autolink/view/view.go b/pkg/cmd/repo/autolink/view/view.go index 0b212aece..f146cd25b 100644 --- a/pkg/cmd/repo/autolink/view/view.go +++ b/pkg/cmd/repo/autolink/view/view.go @@ -78,7 +78,7 @@ func viewRun(opts *viewOptions) error { return opts.Exporter.Write(opts.IO, autolink) } - fmt.Fprintf(out, "Autolink in %s\n\n", ghrepo.FullName(repo)) + fmt.Fprintf(out, "Autolink in %s\n\n", cs.Bold(ghrepo.FullName(repo))) fmt.Fprint(out, cs.Bold("ID: ")) fmt.Fprintln(out, cs.Cyanf("%d", autolink.ID))