Skip to content

Commit c0f993a

Browse files
authored
Merge pull request cli#10846 from cli/kw/accessible-prompter-and-disable-spinners-config
`gh config`: add config settings for accessible prompter and disabling spinner
2 parents 41f9450 + 5316f05 commit c0f993a

11 files changed

Lines changed: 330 additions & 43 deletions

File tree

internal/config/config.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
// they are defined here to avoid `cli/cli` being changed unexpectedly.
1919
const (
2020
accessibleColorsKey = "accessible_colors" // used by cli/go-gh to enable the use of customizable, accessible 4-bit colors.
21+
accessiblePrompterKey = "accessible_prompter"
2122
aliasesKey = "aliases"
2223
browserKey = "browser" // used by cli/go-gh to open URLs in web browsers
2324
colorLabelsKey = "color_labels"
@@ -29,6 +30,7 @@ const (
2930
pagerKey = "pager"
3031
promptKey = "prompt"
3132
preferEditorPromptKey = "prefer_editor_prompt"
33+
spinnerKey = "spinner"
3234
userKey = "user"
3335
usersKey = "users"
3436
versionKey = "version"
@@ -117,6 +119,11 @@ func (c *cfg) AccessibleColors(hostname string) gh.ConfigEntry {
117119
return c.GetOrDefault(hostname, accessibleColorsKey).Unwrap()
118120
}
119121

122+
func (c *cfg) AccessiblePrompter(hostname string) gh.ConfigEntry {
123+
// Intentionally panic if there is no user provided value or default value (which would be a programmer error)
124+
return c.GetOrDefault(hostname, accessiblePrompterKey).Unwrap()
125+
}
126+
120127
func (c *cfg) Browser(hostname string) gh.ConfigEntry {
121128
// Intentionally panic if there is no user provided value or default value (which would be a programmer error)
122129
return c.GetOrDefault(hostname, browserKey).Unwrap()
@@ -157,6 +164,11 @@ func (c *cfg) PreferEditorPrompt(hostname string) gh.ConfigEntry {
157164
return c.GetOrDefault(hostname, preferEditorPromptKey).Unwrap()
158165
}
159166

167+
func (c *cfg) Spinner(hostname string) gh.ConfigEntry {
168+
// Intentionally panic if there is no user provided value or default value (which would be a programmer error)
169+
return c.GetOrDefault(hostname, spinnerKey).Unwrap()
170+
}
171+
160172
func (c *cfg) Version() o.Option[string] {
161173
return c.get("", versionKey)
162174
}
@@ -550,6 +562,10 @@ browser:
550562
color_labels: disabled
551563
# Whether customizable, 4-bit accessible colors should be used. Supported values: enabled, disabled
552564
accessible_colors: disabled
565+
# Whether an accessible prompter should be used. Supported values: enabled, disabled
566+
accessible_prompter: disabled
567+
# Whether to use a animated spinner as a progress indicator. If disabled, a textual progress indicator is used instead. Supported values: enabled, disabled
568+
spinner: enabled
553569
`
554570

555571
type ConfigOption struct {
@@ -638,6 +654,24 @@ var Options = []ConfigOption{
638654
return c.AccessibleColors(hostname).Value
639655
},
640656
},
657+
{
658+
Key: accessiblePrompterKey,
659+
Description: "whether an accessible prompter should be used",
660+
DefaultValue: "disabled",
661+
AllowedValues: []string{"enabled", "disabled"},
662+
CurrentValue: func(c gh.Config, hostname string) string {
663+
return c.AccessiblePrompter(hostname).Value
664+
},
665+
},
666+
{
667+
Key: spinnerKey,
668+
Description: "whether to use a animated spinner as a progress indicator",
669+
DefaultValue: "enabled",
670+
AllowedValues: []string{"enabled", "disabled"},
671+
CurrentValue: func(c gh.Config, hostname string) string {
672+
return c.Spinner(hostname).Value
673+
},
674+
},
641675
}
642676

643677
func HomeDirPath(subdir string) (string, error) {

internal/config/stub.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ func NewFromString(cfgStr string) *ghmock.ConfigMock {
5555
mock.AccessibleColorsFunc = func(hostname string) gh.ConfigEntry {
5656
return cfg.AccessibleColors(hostname)
5757
}
58+
mock.AccessiblePrompterFunc = func(hostname string) gh.ConfigEntry {
59+
return cfg.AccessiblePrompter(hostname)
60+
}
5861
mock.BrowserFunc = func(hostname string) gh.ConfigEntry {
5962
return cfg.Browser(hostname)
6063
}
@@ -79,6 +82,9 @@ func NewFromString(cfgStr string) *ghmock.ConfigMock {
7982
mock.PreferEditorPromptFunc = func(hostname string) gh.ConfigEntry {
8083
return cfg.PreferEditorPrompt(hostname)
8184
}
85+
mock.SpinnerFunc = func(hostname string) gh.ConfigEntry {
86+
return cfg.Spinner(hostname)
87+
}
8288
mock.VersionFunc = func() o.Option[string] {
8389
return cfg.Version()
8490
}

internal/gh/gh.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ type Config interface {
3737

3838
// AccessibleColors returns the configured accessible_colors setting, optionally scoped by host.
3939
AccessibleColors(hostname string) ConfigEntry
40+
// AccessiblePrompter returns the configured accessible_prompter setting, optionally scoped by host.
41+
AccessiblePrompter(hostname string) ConfigEntry
4042
// Browser returns the configured browser, optionally scoped by host.
4143
Browser(hostname string) ConfigEntry
4244
// ColorLabels returns the configured color_label setting, optionally scoped by host.
@@ -53,6 +55,8 @@ type Config interface {
5355
Prompt(hostname string) ConfigEntry
5456
// PreferEditorPrompt returns the configured editor-based prompt, optionally scoped by host.
5557
PreferEditorPrompt(hostname string) ConfigEntry
58+
// Spinner returns the configured spinner setting, optionally scoped by host.
59+
Spinner(hostname string) ConfigEntry
5660

5761
// Aliases provides persistent storage and modification of command aliases.
5862
Aliases() AliasConfig

internal/gh/mock/config.go

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)