Configure full Docker setup and confirm consequential actions
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (a App) confirmAction(question string, yes bool) error {
|
||||
if yes {
|
||||
return nil
|
||||
}
|
||||
fmt.Fprint(a.Err, question+" [y/N]: ")
|
||||
line, _ := bufio.NewReader(a.In).ReadString('\n')
|
||||
if answer := strings.ToLower(strings.TrimSpace(line)); answer != "y" && answer != "yes" {
|
||||
return fmt.Errorf("action canceled; use --yes for explicit non-interactive confirmation")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user