From 3ff1f17fafa99f7bb1b8be796e624141e5527282 Mon Sep 17 00:00:00 2001 From: Pavel Vorobyov Date: Tue, 24 Sep 2019 12:22:24 +0300 Subject: [PATCH] consistent remote option set --- cli/cli.go | 4 +--- cli/handlers.go | 9 +++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index a88dd26..dd485f9 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -318,10 +318,8 @@ func (c *Cli) doexec(mode execMode, argsLine string) { } c.acquirePasswd() - cmd := string(rest) - remote.SetUser(c.user) - remote.SetRaise(c.raiseType) remote.SetPassword(c.raisePasswd) + cmd := string(rest) if c.execConfirm { fmt.Printf("%s\n", term.Yellow(term.HR(len(cmd)+5))) diff --git a/cli/handlers.go b/cli/handlers.go index b688d1c..06dbf89 100644 --- a/cli/handlers.go +++ b/cli/handlers.go @@ -93,6 +93,7 @@ func (c *Cli) doUser(name string, argsLine string, args ...string) { return } c.user = args[0] + remote.SetUser(c.user) } func (c *Cli) doHostlist(name string, argsLine string, args ...string) { @@ -159,6 +160,7 @@ func (c *Cli) doRaise(name string, argsLine string, args ...string) { // Drop passwd in case of changing raise type c.raisePasswd = "" } + remote.SetRaise(c.raiseType) } func (c *Cli) doPasswd(name string, argsLine string, args ...string) { @@ -193,11 +195,13 @@ func (c *Cli) doSSH(name string, argsLine string, args ...string) { } c.acquirePasswd() + remote.SetPassword(c.raisePasswd) + expr, rest := split([]rune(argsLine)) hosts, err := c.store.HostList([]rune(expr)) if err != nil { - term.Errorf("Error parsing expression %s: %s\n", expr, err) + term.Errorf("Error parsing expression %s: %s\n", string(expr), err) return } @@ -206,9 +210,6 @@ func (c *Cli) doSSH(name string, argsLine string, args ...string) { return } - remote.SetUser(c.user) - remote.SetPassword(c.raisePasswd) - remote.SetRaise(c.raiseType) cmd := string(rest) remote.RunSerial(hosts, cmd, 0) }