From 8e625e0bc353668ad3375052979700bf965f173d Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 16 May 2018 09:09:41 +0100 Subject: [PATCH] config: add ConfirmWithDefault to change the default on AutoConfig --- fs/config/config.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/config/config.go b/fs/config/config.go index 663b5944c..838989f6d 100644 --- a/fs/config/config.go +++ b/fs/config/config.go @@ -539,14 +539,23 @@ func Command(commands []string) byte { } } -// Confirm asks the user for Yes or No and returns true or false -func Confirm() bool { +// ConfirmWithDefault asks the user for Yes or No and returns true or false. +// +// If AutoConfirm is set, it will return the Default value passed in +func ConfirmWithDefault(Default bool) bool { if fs.Config.AutoConfirm { - return true + return Default } return Command([]string{"yYes", "nNo"}) == 'y' } +// Confirm asks the user for Yes or No and returns true or false +// +// If AutoConfirm is set, it will return true +func Confirm() bool { + return ConfirmWithDefault(true) +} + // Choose one of the defaults or type a new string if newOk is set func Choose(what string, defaults, help []string, newOk bool) string { valueDescripton := "an existing"