From 9f7e6a19ab49048ad6ed6e80dd4593cdd60d895b Mon Sep 17 00:00:00 2001 From: Josh Curl Date: Tue, 7 Jun 2016 22:16:23 -0700 Subject: [PATCH] Add --force flag to console switch --- cmd/control/console.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/control/console.go b/cmd/control/console.go index 5096d2e0..acaa2a23 100644 --- a/cmd/control/console.go +++ b/cmd/control/console.go @@ -24,6 +24,12 @@ func consoleSubcommands() []cli.Command { Name: "switch", Usage: "switch currently running console", Action: consoleSwitch, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "force, f", + Usage: "do not prompt for input", + }, + }, }, { Name: "list", @@ -39,10 +45,12 @@ func consoleSwitch(c *cli.Context) error { } newConsole := c.Args()[0] - in := bufio.NewReader(os.Stdin) - question := fmt.Sprintf("Switching consoles will destroy the current console container and restart Docker. Continue") - if !yes(in, question) { - return nil + if !c.Bool("force") { + in := bufio.NewReader(os.Stdin) + question := fmt.Sprintf("Switching consoles will destroy the current console container and restart Docker. Continue") + if !yes(in, question) { + return nil + } } cfg := config.LoadConfig()