console/prompt: return err if err != nil

This commit is contained in:
Weixie Cui 2026-05-24 11:33:34 +08:00
parent efe58eac00
commit 2248ac1e28

View file

@ -143,10 +143,13 @@ func (p *terminalPrompter) PromptPassword(prompt string) (passwd string, err err
// choice to be made, returning that choice. // choice to be made, returning that choice.
func (p *terminalPrompter) PromptConfirm(prompt string) (bool, error) { func (p *terminalPrompter) PromptConfirm(prompt string) (bool, error) {
input, err := p.PromptInput(prompt + " [y/n] ") input, err := p.PromptInput(prompt + " [y/n] ")
if err != nil {
return false, err
}
if len(input) > 0 && strings.EqualFold(input[:1], "y") { if len(input) > 0 && strings.EqualFold(input[:1], "y") {
return true, nil return true, nil
} }
return false, err return false, nil
} }
// SetHistory sets the input scrollback history that the prompter will allow // SetHistory sets the input scrollback history that the prompter will allow