From 647a16dacba7f47d71e61169c22171cf2734beec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Wed, 19 Jun 2024 21:51:56 -0700 Subject: [PATCH] add flag for confirmation only confirm if flag is passed --- main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.go b/main.go index 2053f1a..1426dbd 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,7 @@ var ( o, b, a, g, p string ung, unp string fo, do, ih bool + askconfirm bool workdir, ogdir cli.Path recursive bool termwidth int @@ -242,6 +243,14 @@ var ( Aliases: []string{"l"}, Destination: &loglvl, }, + &cli.BoolFlag{ + Name: "confirm", + Usage: "ask for confirmation before executing any action", + Value: false, + Aliases: []string{"c"}, + DisableDefaultText: true, + Destination: &askconfirm, + }, } filter_flags = []cli.Flag{ @@ -452,6 +461,9 @@ func confirm_trash(fs files.Files) error { } func confirm(prompt string) bool { + if !askconfirm { + return true + } // TODO: handle errors better // switch stdin into 'raw' mode oldState, err := term.MakeRaw(int(os.Stdin.Fd()))