Skip to content

Commit

Permalink
add all option for input prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
iychoi committed Sep 4, 2024
1 parent 0b5e098 commit 2fb5285
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion commons/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
"golang.org/x/term"
)

var (
selectedAll bool = false
)

func Input(msg string) string {
terminalWriter := GetTerminalWriter()

Expand All @@ -29,13 +33,20 @@ func Input(msg string) string {
// InputYN inputs Y or N
// true for Y, false for N
func InputYN(msg string) bool {
if selectedAll {
return true
}

for {
inputString := Input(fmt.Sprintf("%s [y/n]", msg))
inputString := Input(fmt.Sprintf("%s [yes(y)/no(n)/all(a)]", msg))
inputString = strings.ToLower(inputString)
if inputString == "y" || inputString == "yes" || inputString == "true" {
return true
} else if inputString == "n" || inputString == "no" || inputString == "false" {
return false
} else if inputString == "a" || inputString == "all" {
selectedAll = true
return true
}
}
}
Expand Down

0 comments on commit 2fb5285

Please sign in to comment.