diff options
Diffstat (limited to 'cmd/fscrypt/prompt.go')
| -rw-r--r-- | cmd/fscrypt/prompt.go | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/cmd/fscrypt/prompt.go b/cmd/fscrypt/prompt.go index 0031e8f..bccf534 100644 --- a/cmd/fscrypt/prompt.go +++ b/cmd/fscrypt/prompt.go @@ -25,7 +25,6 @@ import ( "os" "os/user" "strconv" - "strings" "github.com/pkg/errors" @@ -47,67 +46,6 @@ var sourceDescriptions = map[metadata.SourceType]string{ metadata.SourceType_raw_key: "A raw 256-bit key", } -// askQuestion asks the user a yes or no question. Returning a boolean on a -// successful answer and an error if there was not a response from the user. -// Returns the defaultChoice on empty input (or in quiet mode). -func askQuestion(question string, defaultChoice bool) (bool, error) { - // If in quiet mode, we just use the default - if quietFlag.Value { - return defaultChoice, nil - } - // Loop until failure or valid input - for { - if defaultChoice { - fmt.Print(question + defaultYesSuffix) - } else { - fmt.Print(question + defaultNoSuffix) - } - - input, err := util.ReadLine() - if err != nil { - return false, err - } - - switch strings.ToLower(input) { - case "y", "yes": - return true, nil - case "n", "no": - return false, nil - case "": - return defaultChoice, nil - } - } -} - -// askConfirmation asks the user for confirmation of a specific action. An error -// is returned if the user declines or IO fails. -func askConfirmation(question string, defaultChoice bool, warning string) error { - // All confirmations are "yes" if we are forcing. - if forceFlag.Value { - return nil - } - - // Defaults of "no" require forcing. - if !defaultChoice { - if quietFlag.Value { - return ErrNoDesctructiveOps - } - } - - if warning != "" && !quietFlag.Value { - fmt.Println(wrapText("WARNING: "+warning, 0)) - } - - confirmed, err := askQuestion(question, defaultChoice) - if err != nil { - return err - } - if !confirmed { - return ErrCanceled - } - return nil -} - // usernameFromID returns the username for the provided UID. If the UID does not // correspond to a user or the username is blank, an error is returned. func usernameFromID(uid int64) (string, error) { |