From 2878ba2effed368a894b06b56d45684699bb5896 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 5 Jul 2016 12:09:08 -0700 Subject: [PATCH] Update action for cli package --- main.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index a0d882f..2f3de17 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "fmt" "net" "os" "path/filepath" @@ -44,25 +45,25 @@ func loadHosts(context *cli.Context) ([]string, error) { // multiplexAction uses the arguments passed via the command line and // multiplexes them across multiple SSH connections -func multiplexAction(context *cli.Context) { +func multiplexAction(context *cli.Context) error { c, err := newCommand(context) if err != nil { - log.Fatal(err) + return err } log.Debug(c) hosts, err := loadHosts(context) if err != nil { - log.Fatal(err) + return err } sections, err := parseSSHConfigFile(filepath.Join(os.Getenv("HOME"), ".ssh", "config")) if err != nil { - log.Fatal(err) + return err } if len(hosts) == 0 { - log.Fatal("no host specified for command to run") + return fmt.Errorf("no host specified for command to run") } log.Debugf("hosts %v", hosts) group := &sync.WaitGroup{} @@ -72,6 +73,7 @@ func multiplexAction(context *cli.Context) { } group.Wait() log.Debugf("finished executing %s on all hosts", c) + return nil } func executeCommand(c command, host string, section *SSHConfigFileSection, agentForwarding, quiet bool, group *sync.WaitGroup) { @@ -141,7 +143,7 @@ func main() { app := cli.NewApp() app.Name = "slex" app.Usage = "SSH commands multiplexed" - app.Version = "1" + app.Version = "2" app.Author = "@crosbymichael" app.Email = "crosbymichael@gmail.com" app.Before = preload