From d2cd14b4cdb32d5edf97294dac9a462672450924 Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Mon, 31 Mar 2025 11:58:30 -0400 Subject: [PATCH] Remove out of scope changes, update list commands After discussing this with the team, the `gh config` changes to display `accessible_colors` have been removed from this branch being outside of acceptance criteria. This will be moved to a separate issue along with any other work needed to finalize the public preview such as `gh help` entries for `GH_ACCESSIBLE_COLORS` environment variable. List commands that use ColorScheme.Gray have been updated to use ColorScheme.Muted. --- internal/config/config.go | 14 -------------- internal/gh/gh.go | 2 -- pkg/cmd/cache/list/list.go | 9 +++++---- pkg/cmd/codespace/list.go | 4 ++-- pkg/cmd/gist/list/list.go | 2 +- pkg/cmd/gpg-key/list/list.go | 4 ++-- pkg/cmd/pr/list/list.go | 2 +- pkg/cmd/release/list/list.go | 10 +++++----- pkg/cmd/repo/deploy-key/list/list.go | 2 +- pkg/cmd/repo/list/list.go | 4 ++-- pkg/cmd/run/list/list.go | 2 +- pkg/cmd/ssh-key/list/list.go | 4 ++-- 12 files changed, 22 insertions(+), 37 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 51116df6c..a3849b9af 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -110,11 +110,6 @@ func (c *cfg) Authentication() gh.AuthConfig { return &AuthConfig{cfg: c.cfg} } -func (c *cfg) AccessibleColors(hostname string) gh.ConfigEntry { - // Intentionally panic if there is no user provided value or default value (which would be a programmer error) - return c.GetOrDefault(hostname, accessibleColorsKey).Unwrap() -} - func (c *cfg) Browser(hostname string) gh.ConfigEntry { // Intentionally panic if there is no user provided value or default value (which would be a programmer error) return c.GetOrDefault(hostname, browserKey).Unwrap() @@ -611,15 +606,6 @@ var Options = []ConfigOption{ return c.Browser(hostname).Value }, }, - { - Key: accessibleColorsKey, - Description: "toggle preference for accessible colors that can be customized", - DefaultValue: "disabled", - AllowedValues: []string{"enabled", "disabled"}, - CurrentValue: func(c gh.Config, hostname string) string { - return c.AccessibleColors(hostname).Value - }, - }, } func HomeDirPath(subdir string) (string, error) { diff --git a/internal/gh/gh.go b/internal/gh/gh.go index 4f3ece204..8e640c41a 100644 --- a/internal/gh/gh.go +++ b/internal/gh/gh.go @@ -35,8 +35,6 @@ type Config interface { // Set provides primitive access for setting configuration values, optionally scoped by host. Set(hostname string, key string, value string) - // AccessibleColors returns the configured accessible colors preference, optionally scoped by host. - AccessibleColors(hostname string) ConfigEntry // Browser returns the configured browser, optionally scoped by host. Browser(hostname string) ConfigEntry // Editor returns the configured editor, optionally scoped by host. diff --git a/pkg/cmd/cache/list/list.go b/pkg/cmd/cache/list/list.go index 9f39876cb..d699e2c3d 100644 --- a/pkg/cmd/cache/list/list.go +++ b/pkg/cmd/cache/list/list.go @@ -99,11 +99,12 @@ func listRun(opts *ListOptions) error { } client := api.NewClientFromHTTP(httpClient) + cs := opts.IO.ColorScheme() opts.IO.StartProgressIndicator() result, err := shared.GetCaches(client, repo, shared.GetCachesOptions{Limit: opts.Limit, Sort: opts.Sort, Order: opts.Order, Key: opts.Key, Ref: opts.Ref}) opts.IO.StopProgressIndicator() if err != nil { - return fmt.Errorf("%s Failed to get caches: %w", opts.IO.ColorScheme().FailureIcon(), err) + return fmt.Errorf("%s Failed to get caches: %w", cs.FailureIcon(), err) } if len(result.ActionsCaches) == 0 && opts.Exporter == nil { @@ -130,11 +131,11 @@ func listRun(opts *ListOptions) error { tp := tableprinter.New(opts.IO, tableprinter.WithHeader("ID", "KEY", "SIZE", "CREATED", "ACCESSED")) for _, cache := range result.ActionsCaches { - tp.AddField(opts.IO.ColorScheme().Cyan(fmt.Sprintf("%d", cache.Id))) + tp.AddField(cs.Cyanf("%d", cache.Id)) tp.AddField(cache.Key) tp.AddField(humanFileSize(cache.SizeInBytes)) - tp.AddTimeField(opts.Now, cache.CreatedAt, opts.IO.ColorScheme().Gray) - tp.AddTimeField(opts.Now, cache.LastAccessedAt, opts.IO.ColorScheme().Gray) + tp.AddTimeField(opts.Now, cache.CreatedAt, cs.Muted) + tp.AddTimeField(opts.Now, cache.LastAccessedAt, cs.Muted) tp.EndRow() } diff --git a/pkg/cmd/codespace/list.go b/pkg/cmd/codespace/list.go index c1acccabb..238c4a6a7 100644 --- a/pkg/cmd/codespace/list.go +++ b/pkg/cmd/codespace/list.go @@ -152,7 +152,7 @@ func (a *App) List(ctx context.Context, opts *listOptions, exporter cmdutil.Expo case false: nameColor = cs.Yellow case true: - nameColor = cs.Gray + nameColor = cs.Muted } tp.AddField(formattedName, tableprinter.WithColor(nameColor)) @@ -172,7 +172,7 @@ func (a *App) List(ctx context.Context, opts *listOptions, exporter cmdutil.Expo if err != nil { return fmt.Errorf("error parsing date %q: %w", c.CreatedAt, err) } - tp.AddTimeField(time.Now(), ct, cs.Gray) + tp.AddTimeField(time.Now(), ct, cs.Muted) if hasNonProdVSCSTarget { tp.AddField(c.VSCSTarget) diff --git a/pkg/cmd/gist/list/list.go b/pkg/cmd/gist/list/list.go index d46d4da02..a4fd245f6 100644 --- a/pkg/cmd/gist/list/list.go +++ b/pkg/cmd/gist/list/list.go @@ -206,7 +206,7 @@ func printTable(io *iostreams.IOStreams, gists []shared.Gist, filter *regexp.Reg tableprinter.WithColor(highlightFilesFunc(&gist)), ) tp.AddField(visibility, tableprinter.WithColor(visColor)) - tp.AddTimeField(time.Now(), gist.UpdatedAt, cs.Gray) + tp.AddTimeField(time.Now(), gist.UpdatedAt, cs.Muted) tp.EndRow() } diff --git a/pkg/cmd/gpg-key/list/list.go b/pkg/cmd/gpg-key/list/list.go index 9acf1d7b6..4244ba349 100644 --- a/pkg/cmd/gpg-key/list/list.go +++ b/pkg/cmd/gpg-key/list/list.go @@ -78,7 +78,7 @@ func listRun(opts *ListOptions) error { t.AddField(gpgKey.Emails.String()) t.AddField(gpgKey.KeyID) t.AddField(gpgKey.PublicKey, tableprinter.WithTruncate(truncateMiddle)) - t.AddTimeField(now, gpgKey.CreatedAt, cs.Gray) + t.AddTimeField(now, gpgKey.CreatedAt, cs.Muted) expiresAt := gpgKey.ExpiresAt.Format(time.RFC3339) if t.IsTTY() { if gpgKey.ExpiresAt.IsZero() { @@ -87,7 +87,7 @@ func listRun(opts *ListOptions) error { expiresAt = gpgKey.ExpiresAt.Format("2006-01-02") } } - t.AddField(expiresAt, tableprinter.WithColor(cs.Gray)) + t.AddField(expiresAt, tableprinter.WithColor(cs.Muted)) t.EndRow() } diff --git a/pkg/cmd/pr/list/list.go b/pkg/cmd/pr/list/list.go index ee708f161..0b86d5e11 100644 --- a/pkg/cmd/pr/list/list.go +++ b/pkg/cmd/pr/list/list.go @@ -224,7 +224,7 @@ func listRun(opts *ListOptions) error { if !isTTY { table.AddField(shared.PrStateWithDraft(&pr)) } - table.AddTimeField(opts.Now(), pr.CreatedAt, cs.Gray) + table.AddTimeField(opts.Now(), pr.CreatedAt, cs.Muted) table.EndRow() } err = table.Render() diff --git a/pkg/cmd/release/list/list.go b/pkg/cmd/release/list/list.go index 24ec41840..dfc3ba8c1 100644 --- a/pkg/cmd/release/list/list.go +++ b/pkg/cmd/release/list/list.go @@ -88,7 +88,7 @@ func listRun(opts *ListOptions) error { } table := tableprinter.New(opts.IO, tableprinter.WithHeader("Title", "Type", "Tag name", "Published")) - iofmt := opts.IO.ColorScheme() + cs := opts.IO.ColorScheme() for _, rel := range releases { title := text.RemoveExcessiveWhitespace(rel.Name) if title == "" { @@ -100,13 +100,13 @@ func listRun(opts *ListOptions) error { var badgeColor func(string) string if rel.IsLatest { badge = "Latest" - badgeColor = iofmt.Green + badgeColor = cs.Green } else if rel.IsDraft { badge = "Draft" - badgeColor = iofmt.Red + badgeColor = cs.Red } else if rel.IsPrerelease { badge = "Pre-release" - badgeColor = iofmt.Yellow + badgeColor = cs.Yellow } table.AddField(badge, tableprinter.WithColor(badgeColor)) @@ -116,7 +116,7 @@ func listRun(opts *ListOptions) error { if rel.PublishedAt.IsZero() { pubDate = rel.CreatedAt } - table.AddTimeField(time.Now(), pubDate, iofmt.Gray) + table.AddTimeField(time.Now(), pubDate, cs.Muted) table.EndRow() } err = table.Render() diff --git a/pkg/cmd/repo/deploy-key/list/list.go b/pkg/cmd/repo/deploy-key/list/list.go index 0cf2861c1..79d00c912 100644 --- a/pkg/cmd/repo/deploy-key/list/list.go +++ b/pkg/cmd/repo/deploy-key/list/list.go @@ -90,7 +90,7 @@ func listRun(opts *ListOptions) error { } t.AddField(sshType) t.AddField(deployKey.Key, tableprinter.WithTruncate(truncateMiddle)) - t.AddTimeField(now, deployKey.CreatedAt, cs.Gray) + t.AddTimeField(now, deployKey.CreatedAt, cs.Muted) t.EndRow() } diff --git a/pkg/cmd/repo/list/list.go b/pkg/cmd/repo/list/list.go index 2cee2c480..116439290 100644 --- a/pkg/cmd/repo/list/list.go +++ b/pkg/cmd/repo/list/list.go @@ -181,7 +181,7 @@ func listRun(opts *ListOptions) error { totalMatchCount := len(listResult.Repositories) for _, repo := range listResult.Repositories { info := repoInfo(repo) - infoColor := cs.Gray + infoColor := cs.Muted if repo.IsPrivate { infoColor = cs.Yellow @@ -195,7 +195,7 @@ func listRun(opts *ListOptions) error { tp.AddField(repo.NameWithOwner, tableprinter.WithColor(cs.Bold)) tp.AddField(text.RemoveExcessiveWhitespace(repo.Description)) tp.AddField(info, tableprinter.WithColor(infoColor)) - tp.AddTimeField(opts.Now(), *t, cs.Gray) + tp.AddTimeField(opts.Now(), *t, cs.Muted) tp.EndRow() } diff --git a/pkg/cmd/run/list/list.go b/pkg/cmd/run/list/list.go index 7b18c391d..7128ae253 100644 --- a/pkg/cmd/run/list/list.go +++ b/pkg/cmd/run/list/list.go @@ -176,7 +176,7 @@ func listRun(opts *ListOptions) error { tp.AddField(string(run.Event)) tp.AddField(fmt.Sprintf("%d", run.ID), tableprinter.WithColor(cs.Cyan)) tp.AddField(run.Duration(opts.now).String()) - tp.AddTimeField(opts.now, run.StartedTime(), cs.Gray) + tp.AddTimeField(opts.now, run.StartedTime(), cs.Muted) tp.EndRow() } diff --git a/pkg/cmd/ssh-key/list/list.go b/pkg/cmd/ssh-key/list/list.go index eebc82f90..f69e57ea3 100644 --- a/pkg/cmd/ssh-key/list/list.go +++ b/pkg/cmd/ssh-key/list/list.go @@ -89,11 +89,11 @@ func listRun(opts *ListOptions) error { t.AddField(id) t.AddField(sshKey.Key, tableprinter.WithTruncate(truncateMiddle)) t.AddField(sshKey.Type) - t.AddTimeField(now, sshKey.CreatedAt, cs.Gray) + t.AddTimeField(now, sshKey.CreatedAt, cs.Muted) } else { t.AddField(sshKey.Title) t.AddField(sshKey.Key) - t.AddTimeField(now, sshKey.CreatedAt, cs.Gray) + t.AddTimeField(now, sshKey.CreatedAt, cs.Muted) t.AddField(id) t.AddField(sshKey.Type) }