pkg/utils: Add function to prompt the user for confirmation
https://github.com/containers/toolbox/pull/318
This commit is contained in:
parent
823fbacea9
commit
936f22ff15
1 changed files with 26 additions and 0 deletions
|
@ -97,6 +97,32 @@ func init() {
|
|||
ContainerNameDefault = ContainerNamePrefixDefault + "-" + releaseDefault
|
||||
}
|
||||
|
||||
func AskForConfirmation(prompt string) bool {
|
||||
var retVal bool
|
||||
|
||||
for {
|
||||
fmt.Printf("%s ", prompt)
|
||||
|
||||
var response string
|
||||
|
||||
fmt.Scanf("%s", &response)
|
||||
if response == "" {
|
||||
response = "n"
|
||||
} else {
|
||||
response = strings.ToLower(response)
|
||||
}
|
||||
|
||||
if response == "no" || response == "n" {
|
||||
break
|
||||
} else if response == "yes" || response == "y" {
|
||||
retVal = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return retVal
|
||||
}
|
||||
|
||||
func CallFlatpakSessionHelper() (string, error) {
|
||||
logrus.Debug("Calling org.freedesktop.Flatpak.SessionHelper.RequestSession")
|
||||
|
||||
|
|
Loading…
Reference in a new issue