Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ import (
ghConfig "github.com/cli/go-gh/v2/pkg/config"
)

// Important: some of the following configuration settings are used outside of `cli/cli`,
// they are defined here to avoid `cli/cli` being changed unexpectedly.
const (
accessibleColorsKey = "accessible_colors" // used by cli/go-gh to enable the use of customizable, accessible 4-bit colors.
aliasesKey = "aliases"
browserKey = "browser"
browserKey = "browser" // used by cli/go-gh to open URLs in web browsers
colorLabelsKey = "color_labels"
editorKey = "editor"
editorKey = "editor" // used by cli/go-gh to open interactive text editor
gitProtocolKey = "git_protocol"
hostsKey = "hosts"
hostsKey = "hosts" // used by cli/go-gh to locate authenticated host tokens
httpUnixSocketKey = "http_unix_socket"
oauthTokenKey = "oauth_token"
oauthTokenKey = "oauth_token" // used by cli/go-gh to locate authenticated host tokens
pagerKey = "pager"
promptKey = "prompt"
preferEditorPromptKey = "prefer_editor_prompt"
Expand Down Expand Up @@ -109,6 +112,11 @@ 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()
Expand Down Expand Up @@ -540,6 +548,8 @@ http_unix_socket:
browser:
# Whether to display labels using their RGB hex color codes in terminals that support truecolor. Supported values: enabled, disabled
color_labels: disabled
# Whether customizable, 4-bit accessible colors should be used. Supported values: enabled, disabled
accessible_colors: disabled
`

type ConfigOption struct {
Expand Down Expand Up @@ -619,6 +629,15 @@ var Options = []ConfigOption{
return c.ColorLabels(hostname).Value
},
},
{
Key: accessibleColorsKey,
Description: "whether customizable, 4-bit accessible colors should be used",
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) {
Expand Down
3 changes: 3 additions & 0 deletions internal/config/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func NewFromString(cfgStr string) *ghmock.ConfigMock {
},
}
}
mock.AccessibleColorsFunc = func(hostname string) gh.ConfigEntry {
return cfg.AccessibleColors(hostname)
}
mock.BrowserFunc = func(hostname string) gh.ConfigEntry {
return cfg.Browser(hostname)
}
Expand Down
2 changes: 2 additions & 0 deletions internal/gh/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ 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 setting, optionally scoped by host.
AccessibleColors(hostname string) ConfigEntry
// Browser returns the configured browser, optionally scoped by host.
Browser(hostname string) ConfigEntry
// ColorLabels returns the configured color_label setting, optionally scoped by host.
Expand Down
44 changes: 44 additions & 0 deletions internal/gh/mock/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading