Skip to content

Commit e82effe

Browse files
committed
fix: respect default value in prompt when input is empty
Signed-off-by: L. Jiang <l.jiang.1024@gmail.com>
1 parent f9828df commit e82effe

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cmd/prompt/prompt.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,8 @@ func (u Pipe) Confirm(message string, defaultValue bool) (bool, error) {
9898
_, _ = fmt.Fprint(u.stdout, message)
9999
var answer string
100100
_, _ = fmt.Fscanln(u.stdin, &answer)
101+
if answer == "" {
102+
return defaultValue, nil
103+
}
101104
return utils.StringToBool(answer), nil
102105
}

0 commit comments

Comments
 (0)