Skip to content

Commit

Permalink
Merge pull request #3 from MeztliRA/add-response-type
Browse files Browse the repository at this point in the history
Add response type and change return value of all function from string…
  • Loading branch information
MeztliRA authored Mar 31, 2021
2 parents 81a5600 + 4aad985 commit 638b953
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions yon.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ import (
"strings"
)

type Response string

const (
Yes = "YES"
No = "NO"
Yes = Response("YES")
No = Response("NO")
)

func Prompt(prompt string) string {
func Prompt(prompt string) Response {
answer := promptCore(prompt+"(yes/no) ", false)
return answer
}

func Promptln(prompt string) string {
func Promptln(prompt string) Response {
answer := promptCore(prompt+"(yes/no)", true)
return answer
}

func promptCore(prompt string, ln bool) string {
func promptCore(prompt string, ln bool) Response {
log.SetPrefix("prompt: ")
log.SetFlags(0)

Expand Down

0 comments on commit 638b953

Please sign in to comment.