diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-01-23 15:38:23 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-01-23 15:38:23 +0100 |
commit | a653132a916cfdc8576e14f9e8b7445f615803cc (patch) | |
tree | f8cdaf28382c219ea6299cd53afd01d2343122ed /cmd-sdks.go | |
parent | 75fbc67b5acf3258b604fc53ec096f46fc743270 (diff) |
Added -s | --short option (useful from scripting)
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'cmd-sdks.go')
-rw-r--r-- | cmd-sdks.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/cmd-sdks.go b/cmd-sdks.go index 34f5409..bc9df15 100644 --- a/cmd-sdks.go +++ b/cmd-sdks.go @@ -89,6 +89,10 @@ func initCmdSdks(cmdDef *[]cli.Command) { Name: "force", Usage: "force SDK installation when already installed", }, + cli.BoolFlag{ + Name: "short, s", + Usage: "short output, only print create sdk id (useful from scripting)", + }, }, }, { @@ -214,6 +218,7 @@ func sdksInstall(ctx *cli.Context) error { id := GetID(ctx) file := ctx.String("file") force := ctx.Bool("force") + shortOut := ctx.Bool("short") if id == "" && file == "" { return cli.NewExitError("id or file parameter or option must be set", 1) @@ -281,7 +286,9 @@ func sdksInstall(ctx *cli.Context) error { return cli.NewExitError(err, 1) } Log.Debugf("Result of %s: %v", url, newSdk) - fmt.Printf("Installation of '%s' SDK successfully started.\n", newSdk.Name) + if !shortOut { + fmt.Printf("Installation of '%s' SDK successfully started.\n", newSdk.Name) + } // TODO: trap CTRL+C and print question: "Installation of xxx is in progress, press 'a' to abort, 'b' to continue in background or 'c' to continue installation" @@ -290,7 +297,11 @@ func sdksInstall(ctx *cli.Context) error { case res := <-exitChan: if res.code == 0 { Log.Debugln("Exit successfully") - fmt.Println("SDK ID " + newSdk.ID + " successfully installed.") + if shortOut { + fmt.Println(newSdk.ID) + } else { + fmt.Println("SDK ID " + newSdk.ID + " successfully installed.") + } } if res.error != "" { Log.Debugln("Exit with ERROR: ", res.error) |