This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git

commit 7609d52620f6d010b063961153b35491d2a639ed
Author: Benjamin Poole <benjamin.d.po...@ibm.com>
AuthorDate: Fri Aug 4 15:03:20 2017 -0400

    Prints bashauto-completion install script to STDOUT (#2520)
    
    * Prints bash-completion script to STDOUT
    
    * Update docs to include Linux/Mac bash verisons needed
    
    * Reverted to original install but now includes --stdout flag
---
 commands/flags.go                |  5 +++++
 commands/sdk.go                  | 32 ++++++++++++++++++++++----------
 wski18n/resources/en_US.all.json | 10 +++++++++-
 3 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/commands/flags.go b/commands/flags.go
index d7bf302..7ef23d6 100644
--- a/commands/flags.go
+++ b/commands/flags.go
@@ -106,6 +106,11 @@ type FlagsStruct struct {
         summary bool
     }
 
+    //sdk
+    sdk struct {
+        stdout bool
+    }
+
     // api
     api        struct {
         action     string
diff --git a/commands/sdk.go b/commands/sdk.go
index aac6e51..634e2f0 100644
--- a/commands/sdk.go
+++ b/commands/sdk.go
@@ -74,17 +74,27 @@ var sdkInstallCmd = &cobra.Command{
         case "ios":
             err = iOSInstall()
         case "bashauto":
-            err = WskCmd.GenBashCompletionFile(BASH_AUTOCOMPLETE_FILENAME)
-            if (err != nil) {
-                whisk.Debug(whisk.DbgError, "GenBashCompletionFile('%s`) 
error: \n", BASH_AUTOCOMPLETE_FILENAME, err)
-                errStr := wski18n.T("Unable to generate '{{.name}}': {{.err}}",
-                        map[string]interface{}{"name": 
BASH_AUTOCOMPLETE_FILENAME, "err": err})
-                werr := whisk.MakeWskError(errors.New(errStr), 
whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-                return werr
-            }
-            fmt.Printf(
-                wski18n.T("bash_completion_msg",
+            if flags.sdk.stdout {
+                if err = WskCmd.GenBashCompletion(os.Stdout); err != nil {
+                    whisk.Debug(whisk.DbgError, "GenBashCompletion error: 
%s\n", err)
+                    errStr := wski18n.T("Unable to output bash command 
completion {{.err}}",
+                            map[string]interface{}{"err": err})
+                    werr := whisk.MakeWskError(errors.New(errStr), 
whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
+                    return werr
+                }
+             } else {
+                    err = 
WskCmd.GenBashCompletionFile(BASH_AUTOCOMPLETE_FILENAME)
+                    if (err != nil) {
+                        whisk.Debug(whisk.DbgError, 
"GenBashCompletionFile('%s`) error: \n", BASH_AUTOCOMPLETE_FILENAME, err)
+                        errStr := wski18n.T("Unable to generate '{{.name}}': 
{{.err}}",
+                                map[string]interface{}{"name": 
BASH_AUTOCOMPLETE_FILENAME, "err": err})
+                        werr := whisk.MakeWskError(errors.New(errStr), 
whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
+                        return werr
+                    }
+                    fmt.Printf(
+                        wski18n.T("bash_completion_msg",
                     map[string]interface{}{"name": 
BASH_AUTOCOMPLETE_FILENAME}))
+             }
         default:
             whisk.Debug(whisk.DbgError, "Invalid component argument '%s'\n", 
component)
             errStr := wski18n.T("The SDK component argument '{{.component}}' 
is invalid. Valid components are docker, ios and bashauto",
@@ -238,6 +248,8 @@ func sdkInstall(componentName string) error {
 }
 
 func init() {
+    sdkInstallCmd.Flags().BoolVarP(&flags.sdk.stdout, "stdout", "s", false, 
wski18n.T("prints bash command completion script to stdout"))
+
     sdkCmd.AddCommand(sdkInstallCmd)
 
     sdkMap = make(map[string]*sdkInfo)
diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json
index 9b513a3..5608728 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -1518,5 +1518,13 @@
   {
     "id": "get action url",
     "translation": "get action url"
-  }
+  },
+  {
+    "id": "Unable to output bash command completion {{.err}}",
+    "translation": "Unable to output bash command completion {{.err}}"
+},
+{
+    "id": "prints bash command completion script to stdout",
+    "translation": "prints bash command completion script to stdout"
+}
 ]

-- 
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>.

Reply via email to