Skip to content

Commit f70957b

Browse files
committed
Force prompt option should override non-interactive option.
1 parent 63973c6 commit f70957b

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

internal/prompt/prompt.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ func (p *Prompt) InputAndValidate(title, message string, defaultResponse *string
129129
if nonInteractiveResponse == nil {
130130
return "", ErrNoForceOption
131131
}
132-
}
133-
134-
if !p.isInteractive {
132+
} else if !p.isInteractive {
135133
nonInteractiveResponse = defaultResponse
136134
if nonInteractiveResponse == nil {
137135
return "", interactiveInputError(message)
@@ -194,9 +192,7 @@ func (p *Prompt) Select(title, message string, choices []string, defaultChoice *
194192
if nonInteractiveChoice == nil {
195193
return "", ErrNoForceOption
196194
}
197-
}
198-
199-
if !p.isInteractive {
195+
} else if !p.isInteractive {
200196
nonInteractiveChoice = defaultChoice
201197
if nonInteractiveChoice == nil {
202198
return "", interactiveInputError(message)
@@ -253,9 +249,7 @@ func (p *Prompt) Confirm(title, message string, defaultChoice *bool, forcedChoic
253249
if nonInteractiveChoice == nil {
254250
return false, ErrNoForceOption
255251
}
256-
}
257-
258-
if !p.isInteractive {
252+
} else if !p.isInteractive {
259253
nonInteractiveChoice = defaultChoice
260254
if nonInteractiveChoice == nil {
261255
return false, interactiveInputError(message)

0 commit comments

Comments
 (0)