Disable interactive prompting with GH_PROMPT_DISABLED (#6082)
This commit is contained in:
parent
200516beb8
commit
43325fb3e1
3 changed files with 16 additions and 1 deletions
|
|
@ -183,7 +183,9 @@ func ioStreams(f *cmdutil.Factory) *iostreams.IOStreams {
|
|||
return io
|
||||
}
|
||||
|
||||
if prompt, _ := cfg.GetOrDefault("", "prompt"); prompt == "disabled" {
|
||||
if _, ghPromptDisabled := os.LookupEnv("GH_PROMPT_DISABLED"); ghPromptDisabled {
|
||||
io.SetNeverPrompt(true)
|
||||
} else if prompt, _ := cfg.GetOrDefault("", "prompt"); prompt == "disabled" {
|
||||
io.SetNeverPrompt(true)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -352,6 +352,7 @@ func Test_ioStreams_prompt(t *testing.T) {
|
|||
name string
|
||||
config config.Config
|
||||
promptDisabled bool
|
||||
env map[string]string
|
||||
}{
|
||||
{
|
||||
name: "default config",
|
||||
|
|
@ -362,9 +363,19 @@ func Test_ioStreams_prompt(t *testing.T) {
|
|||
config: disablePromptConfig(),
|
||||
promptDisabled: true,
|
||||
},
|
||||
{
|
||||
name: "prompt disabled via GH_PROMPT_DISABLED env var",
|
||||
env: map[string]string{"GH_PROMPT_DISABLED": "1"},
|
||||
promptDisabled: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if tt.env != nil {
|
||||
for k, v := range tt.env {
|
||||
t.Setenv(k, v)
|
||||
}
|
||||
}
|
||||
f := New("1")
|
||||
f.Config = func() (config.Config, error) {
|
||||
if tt.config == nil {
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ var HelpTopics = map[string]map[string]string{
|
|||
|
||||
GH_CONFIG_DIR: the directory where gh will store configuration files. Default:
|
||||
"$XDG_CONFIG_HOME/gh" or "$HOME/.config/gh".
|
||||
|
||||
GH_PROMPT_DISABLED: set to any value to disable interactive prompting in the terminal.
|
||||
`),
|
||||
},
|
||||
"reference": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue