openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From houshen...@apache.org
Subject [incubator-openwhisk-cli] 01/01: Error when Entity Names are Provided to List Commands (#2075)
Date Thu, 22 Jun 2017 04:08:42 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit a31c115b25eaa90c383de187a8aa30c33dd7fe75
Author: James Dubee <jwdubee@us.ibm.com>
AuthorDate: Tue Jun 20 09:27:38 2017 -0400

    Error when Entity Names are Provided to List Commands (#2075)
    
    * Error when Entity Names are Provided to List Commands
    
    - When entity names are pass to list commands display an appropriate error
    - Share qualified name parsing error messages between commands
---
 commands/action.go               |  35 +++-----
 commands/activation.go           |  31 +++----
 commands/api.go                  |  22 ++---
 commands/namespace.go            |  27 ++----
 commands/package.go              | 174 +++++++++++++++------------------------
 commands/rule.go                 | 136 +++++++++++-------------------
 commands/shared.go               |  47 +++++++++++
 commands/trigger.go              | 170 ++++++++++++++------------------------
 commands/util.go                 |  20 ++---
 commands/wsk.go                  |  10 ++-
 wski18n/resources/en_US.all.json |   8 +-
 11 files changed, 289 insertions(+), 391 deletions(-)

diff --git a/commands/action.go b/commands/action.go
index 8ba3633..6b57621 100644
--- a/commands/action.go
+++ b/commands/action.go
@@ -279,8 +279,8 @@ var actionDeleteCmd = &cobra.Command{
 }
 
 var actionListCmd = &cobra.Command{
-    Use:           "list [NAMESPACE]",
-    Short:         wski18n.T("list all actions"),
+    Use:           "list [ NAMESPACE | PACKAGE_NAME ]",
+    Short:         wski18n.T("list all actions in a namespace or actions contained in a package"),
     SilenceUsage:  true,
     SilenceErrors: true,
     PreRunE:       setupClientConfig,
@@ -289,13 +289,7 @@ var actionListCmd = &cobra.Command{
         var actions []whisk.Action
         var err error
 
-        if len(args) == 1 {
-            if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
-                return parseQualifiedNameError(args[0], err)
-            }
-
-            client.Namespace = qualifiedName.namespace
-        } else if whiskErr := checkArgs(
+        if whiskErr := checkArgs(
             args,
             0,
             1,
@@ -304,6 +298,14 @@ var actionListCmd = &cobra.Command{
             return whiskErr
         }
 
+        if len(args) == 1 {
+            if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+                return parseQualifiedNameError(args[0], err)
+            }
+
+            client.Namespace = qualifiedName.namespace
+        }
+
         options := &whisk.ActionListOptions{
             Skip:  Flags.common.skip,
             Limit: Flags.common.limit,
@@ -617,19 +619,6 @@ func actionInsertError(action *whisk.Action, err error) (error) {
     return nestedError(errMsg, err)
 }
 
-func parseQualifiedNameError(entityName string, err error) (error) {
-    whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", entityName, err)
-
-    errMsg := wski18n.T(
-        "'{{.name}}' is not a valid qualified name: {{.err}}",
-        map[string]interface{}{
-            "name": entityName,
-            "err": err,
-        })
-
-    return nestedError(errMsg, err)
-}
-
 func getJSONFromStringsParamError(params []string, keyValueFormat bool, err error) (error) {
     whisk.Debug(whisk.DbgError, "getJSONFromStrings(%#v, %t) failed: %s\n", params, keyValueFormat, err)
 
@@ -902,7 +891,7 @@ func init() {
     actionCreateCmd.Flags().StringVar(&Flags.action.main, "main", "", wski18n.T("the name of the action entry point (function or fully-qualified method name when applicable)"))
     actionCreateCmd.Flags().IntVarP(&Flags.action.timeout, "timeout", "t", TIMEOUT_LIMIT, wski18n.T("the timeout `LIMIT` in milliseconds after which the action is terminated"))
     actionCreateCmd.Flags().IntVarP(&Flags.action.memory, "memory", "m", MEMORY_LIMIT, wski18n.T("the maximum memory `LIMIT` in MB for the action"))
-    actionCreateCmd.Flags().IntVarP(&flags.action.logsize, "logsize", "l", LOGSIZE_LIMIT, wski18n.T("the maximum log size `LIMIT` in MB for the action"))
+    actionCreateCmd.Flags().IntVarP(&Flags.action.logsize, "logsize", "l", LOGSIZE_LIMIT, wski18n.T("the maximum log size `LIMIT` in MB for the action"))
     actionCreateCmd.Flags().StringSliceVarP(&Flags.common.annotation, "annotation", "a", nil, wski18n.T("annotation values in `KEY VALUE` format"))
     actionCreateCmd.Flags().StringVarP(&Flags.common.annotFile, "annotation-file", "A", "", wski18n.T("`FILE` containing annotation values in JSON format"))
     actionCreateCmd.Flags().StringSliceVarP(&Flags.common.param, "param", "p", nil, wski18n.T("parameter values in `KEY VALUE` format"))
diff --git a/commands/activation.go b/commands/activation.go
index 4584110..347f612 100644
--- a/commands/activation.go
+++ b/commands/activation.go
@@ -51,35 +51,26 @@ var activationListCmd = &cobra.Command{
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
-        qName := QualifiedName{}
+        var qualifiedName QualifiedName
+
+        if whiskErr := checkArgs(args, 0, 1, "Activation list",
+            wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil {
+            return whiskErr
+        }
 
         // Specifying an activation item name filter is optional
         if len(args) == 1 {
             whisk.Debug(whisk.DbgInfo, "Activation item name filter '%s' provided\n", args[0])
-            qName, err = parseQualifiedName(args[0])
-            if err != nil {
-                whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-                errStr := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                        map[string]interface{}{"name": args[0], "err": err})
-                werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-                return werr
-            }
-            ns := qName.namespace
-            if len(ns) == 0 {
-                whisk.Debug(whisk.DbgError, "Namespace '%s' is invalid\n", ns)
-                errStr := wski18n.T("Namespace '{{.name}}' is invalid", map[string]interface{}{"name": ns})
-                werr := whisk.MakeWskError(errors.New(errStr), whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
-                return werr
+
+            if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+                return parseQualifiedNameError(args[0], err)
             }
 
-            client.Namespace = ns
-        } else if whiskErr := checkArgs(args, 0, 1, "Activation list",
-                wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil {
-            return whiskErr
+            client.Namespace = qualifiedName.namespace
         }
 
         options := &whisk.ActivationListOptions{
-            Name:  qName.entityName,
+            Name:  qualifiedName.entityName,
             Limit: Flags.common.limit,
             Skip:  Flags.common.skip,
             Upto:  Flags.activation.upto,
diff --git a/commands/api.go b/commands/api.go
index 30bcad2..11aa494 100644
--- a/commands/api.go
+++ b/commands/api.go
@@ -607,19 +607,13 @@ func parseApi(cmd *cobra.Command, args []string) (*whisk.Api, error) {
     }
 
     // Is the specified action name valid?
-    var qName QualifiedName
+    var qualifiedName QualifiedName
     if (len(args) == 3) {
-        qName = QualifiedName{}
-        qName, err = parseQualifiedName(args[2])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[2], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid action name: {{.err}}",
-                map[string]interface{}{"name": args[2], "err": err})
-            whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
-            return nil, whiskErr
+        if qualifiedName, err = parseQualifiedName(args[2]); err != nil {
+            return nil, parseQualifiedNameError(args[2], err)
         }
-        if (qName.entityName == "") {
+
+        if (qualifiedName.entityName == "") {
             whisk.Debug(whisk.DbgError, "Action name '%s' is invalid\n", args[2])
             errMsg := wski18n.T("'{{.name}}' is not a valid action name.", map[string]interface{}{"name": args[2]})
             whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
@@ -642,10 +636,10 @@ func parseApi(cmd *cobra.Command, args []string) (*whisk.Api, error) {
 
     api.Namespace = client.Config.Namespace
     api.Action = new(whisk.ApiAction)
-    api.Action.BackendUrl = "https://" + client.Config.Host + "/api/v1/namespaces/" + qName.namespace + "/actions/" + qName.entityName
+    api.Action.BackendUrl = "https://" + client.Config.Host + "/api/v1/namespaces/" + qualifiedName.namespace + "/actions/" + qualifiedName.entityName
     api.Action.BackendMethod = "POST"
-    api.Action.Name = qName.entityName
-    api.Action.Namespace = qName.namespace
+    api.Action.Name = qualifiedName.entityName
+    api.Action.Namespace = qualifiedName.namespace
     api.Action.Auth = client.Config.AuthToken
     api.ApiName = apiname
     api.GatewayBasePath = basepath
diff --git a/commands/namespace.go b/commands/namespace.go
index de4e877..3a52396 100644
--- a/commands/namespace.go
+++ b/commands/namespace.go
@@ -67,7 +67,7 @@ var namespaceGetCmd = &cobra.Command{
     SilenceErrors:  true,
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
-        var qName QualifiedName
+        var qualifiedName QualifiedName
         var err error
 
         if whiskErr := checkArgs(args, 0, 1, "Namespace get",
@@ -77,18 +77,16 @@ var namespaceGetCmd = &cobra.Command{
 
         // Namespace argument is optional; defaults to configured property namespace
         if len(args) == 1 {
-            qName, err = parseQualifiedName(args[0])
-            if err != nil {
-                whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-                errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                        map[string]interface{}{"name": args[0], "err": err})
-                werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                    whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-                return werr
+            if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+                return parseQualifiedNameError(args[0], err)
+            }
+
+            if len(qualifiedName.entityName) > 0 {
+                return entityNameError(qualifiedName.entityName)
             }
         }
 
-        namespace, _, err := client.Namespaces.Get(qName.namespace)
+        namespace, _, err := client.Namespaces.Get(qualifiedName.namespace)
 
         if err != nil {
             whisk.Debug(whisk.DbgError, "client.Namespaces.Get(%s) error: %s\n", getClientNamespace(), err)
@@ -110,15 +108,6 @@ var namespaceGetCmd = &cobra.Command{
     },
 }
 
-var listCmd = &cobra.Command{
-    Use:   "list",
-    Short: wski18n.T("list entities in the current namespace"),
-    SilenceUsage:   true,
-    SilenceErrors:  true,
-    PreRunE: setupClientConfig,
-    RunE:   namespaceGetCmd.RunE,
-}
-
 func init() {
     namespaceCmd.AddCommand(
         namespaceListCmd,
diff --git a/commands/package.go b/commands/package.go
index 33e9665..68e75c5 100644
--- a/commands/package.go
+++ b/commands/package.go
@@ -42,6 +42,7 @@ var packageBindCmd = &cobra.Command{
   PreRunE:       setupClientConfig,
   RunE: func(cmd *cobra.Command, args []string) error {
     var err error
+    var pkgQualifiedName, bindQualifiedName QualifiedName
 
     if whiskErr := checkArgs(args, 2, 2, "Package bind",
             wski18n.T("A package name and binding name are required.")); whiskErr != nil {
@@ -49,28 +50,16 @@ var packageBindCmd = &cobra.Command{
     }
 
     packageName := args[0]
-    pkgQName, err := parseQualifiedName(packageName)
-    if err != nil {
-      whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", packageName, err)
-      errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-          map[string]interface{}{"name": packageName, "err": err})
-      werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-        whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-      return werr
+    if pkgQualifiedName, err = parseQualifiedName(packageName); err != nil {
+      return parseQualifiedNameError(packageName, err)
     }
 
     bindingName := args[1]
-    bindQName, err := parseQualifiedName(bindingName)
-    if err != nil {
-      whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", bindingName, err)
-      errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-          map[string]interface{}{"name": bindingName, "err": err})
-      werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-        whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-      return werr
+    if bindQualifiedName, err = parseQualifiedName(bindingName); err != nil {
+      return parseQualifiedNameError(bindingName, err)
     }
 
-    client.Namespace = bindQName.namespace
+    client.Namespace = bindQualifiedName.namespace
 
     // Convert the binding's list of default parameters from a string into []KeyValue
     // The 1 or more --param arguments have all been combined into a single []string
@@ -102,12 +91,12 @@ var packageBindCmd = &cobra.Command{
     }
 
     binding := whisk.Binding{
-      Name:      pkgQName.entityName,
-      Namespace: pkgQName.namespace,
+      Name:      pkgQualifiedName.entityName,
+      Namespace: pkgQualifiedName.namespace,
     }
 
     p := &whisk.BindingPackage{
-      Name:        bindQName.entityName,
+      Name:        bindQualifiedName.entityName,
       Annotations: annotations.(whisk.KeyValueArr),
       Parameters:  parameters.(whisk.KeyValueArr),
       Binding:     binding,
@@ -136,21 +125,17 @@ var packageCreateCmd = &cobra.Command{
   RunE: func(cmd *cobra.Command, args []string) error {
     var err error
     var shared, sharedSet bool
+    var qualifiedName QualifiedName
 
     if whiskErr := checkArgs(args, 1, 1, "Package create", wski18n.T("A package name is required.")); whiskErr != nil {
       return whiskErr
     }
 
-    qName, err := parseQualifiedName(args[0])
-    if err != nil {
-      whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-      errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-          map[string]interface{}{"name": args[0], "err": err})
-      werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-        whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-      return werr
+    if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+      return parseQualifiedNameError(args[0], err)
     }
-    client.Namespace = qName.namespace
+
+    client.Namespace = qualifiedName.namespace
 
     if shared, sharedSet, err = parseShared(Flags.common.shared); err != nil {
       whisk.Debug(whisk.DbgError, "parseShared(%s) failed: %s\n", Flags.common.shared, err)
@@ -180,8 +165,8 @@ var packageCreateCmd = &cobra.Command{
     }
 
     p := &whisk.Package{
-      Name:        qName.entityName,
-      Namespace:   qName.namespace,
+      Name:        qualifiedName.entityName,
+      Namespace:   qualifiedName.namespace,
       Annotations: annotations.(whisk.KeyValueArr),
       Parameters:  parameters.(whisk.KeyValueArr),
     }
@@ -196,7 +181,7 @@ var packageCreateCmd = &cobra.Command{
       errStr := wski18n.T(
         "Unable to create package '{{.name}}': {{.err}}",
         map[string]interface{}{
-          "name": qName.entityName,
+          "name": qualifiedName.entityName,
           "err": err,
         })
       werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
@@ -204,7 +189,7 @@ var packageCreateCmd = &cobra.Command{
     }
 
     fmt.Fprintf(color.Output, wski18n.T("{{.ok}} created package {{.name}}\n",
-      map[string]interface{}{"ok": color.GreenString(wski18n.T("ok:")), "name":boldString(qName.entityName)}))
+      map[string]interface{}{"ok": color.GreenString(wski18n.T("ok:")), "name":boldString(qualifiedName.entityName)}))
     return nil
   },
 }
@@ -218,21 +203,17 @@ var packageUpdateCmd = &cobra.Command{
   RunE: func(cmd *cobra.Command, args []string) error {
     var err error
     var shared, sharedSet bool
+    var qualifiedName QualifiedName
 
     if whiskErr := checkArgs(args, 1, 1, "Package update", wski18n.T("A package name is required.")); whiskErr != nil {
       return whiskErr
     }
 
-    qName, err := parseQualifiedName(args[0])
-    if err != nil {
-      whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-      errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-          map[string]interface{}{"name": args[0], "err": err})
-      werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-        whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-      return werr
+    if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+      return parseQualifiedNameError(args[0], err)
     }
-    client.Namespace = qName.namespace
+
+    client.Namespace = qualifiedName.namespace
 
     if shared, sharedSet, err = parseShared(Flags.common.shared); err != nil {
       whisk.Debug(whisk.DbgError, "parseShared(%s) failed: %s\n", Flags.common.shared, err)
@@ -261,8 +242,8 @@ var packageUpdateCmd = &cobra.Command{
     }
 
     p := &whisk.Package{
-      Name:        qName.entityName,
-      Namespace:   qName.namespace,
+      Name:        qualifiedName.entityName,
+      Namespace:   qualifiedName.namespace,
       Annotations: annotations.(whisk.KeyValueArr),
       Parameters:  parameters.(whisk.KeyValueArr),
     }
@@ -280,7 +261,7 @@ var packageUpdateCmd = &cobra.Command{
     }
 
     fmt.Fprintf(color.Output, wski18n.T("{{.ok}} updated package {{.name}}\n",
-      map[string]interface{}{"ok": color.GreenString(wski18n.T("ok:")), "name":boldString(qName.entityName)}))
+      map[string]interface{}{"ok": color.GreenString(wski18n.T("ok:")), "name":boldString(qualifiedName.entityName)}))
     return nil
   },
 }
@@ -294,6 +275,7 @@ var packageGetCmd = &cobra.Command{
   RunE: func(cmd *cobra.Command, args []string) error {
     var err error
     var field string
+    var qualifiedName QualifiedName
 
     if whiskErr := checkArgs(args, 1, 2, "Package get", wski18n.T("A package name is required.")); whiskErr != nil {
       return whiskErr
@@ -310,24 +292,18 @@ var packageGetCmd = &cobra.Command{
       }
     }
 
-    qName, err := parseQualifiedName(args[0])
-    if err != nil {
-      whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-      errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-          map[string]interface{}{"name": args[0], "err": err})
-      werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-        whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-      return werr
+    if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+      return parseQualifiedNameError(args[0], err)
     }
-    client.Namespace = qName.namespace
+    client.Namespace = qualifiedName.namespace
 
-    xPackage, _, err := client.Packages.Get(qName.entityName)
+    xPackage, _, err := client.Packages.Get(qualifiedName.entityName)
     if err != nil {
-      whisk.Debug(whisk.DbgError, "client.Packages.Get(%s) failed: %s\n", qName.entityName, err)
+      whisk.Debug(whisk.DbgError, "client.Packages.Get(%s) failed: %s\n", qualifiedName.entityName, err)
       errStr := wski18n.T(
         "Unable to get package '{{.name}}': {{.err}}",
         map[string]interface{}{
-          "name": qName.entityName,
+          "name": qualifiedName.entityName,
           "err":err,
         })
       werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
@@ -340,12 +316,12 @@ var packageGetCmd = &cobra.Command{
 
       if len(field) > 0 {
         fmt.Fprintf(color.Output, wski18n.T("{{.ok}} got package {{.name}}, displaying field {{.field}}\n",
-          map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qName.entityName),
+          map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qualifiedName.entityName),
           "field": boldString(field)}))
         printField(xPackage, field)
       } else {
         fmt.Fprintf(color.Output, wski18n.T("{{.ok}} got package {{.name}}\n",
-          map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qName.entityName)}))
+          map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qualifiedName.entityName)}))
         printJSON(xPackage)
       }
     }
@@ -362,29 +338,25 @@ var packageDeleteCmd = &cobra.Command{
   PreRunE:       setupClientConfig,
   RunE: func(cmd *cobra.Command, args []string) error {
     var err error
+    var qualifiedName QualifiedName
 
     if whiskErr := checkArgs(args, 1, 1, "Package delete", wski18n.T("A package name is required.")); whiskErr != nil {
       return whiskErr
     }
 
-    qName, err := parseQualifiedName(args[0])
-    if err != nil {
-      whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-      errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-          map[string]interface{}{"name": args[0], "err": err})
-      werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-        whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-      return werr
+    if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+      return parseQualifiedNameError(args[0], err)
     }
-    client.Namespace = qName.namespace
 
-    _, err = client.Packages.Delete(qName.entityName)
+    client.Namespace = qualifiedName.namespace
+
+    _, err = client.Packages.Delete(qualifiedName.entityName)
     if err != nil {
-      whisk.Debug(whisk.DbgError, "client.Packages.Delete(%s) failed: %s\n", qName.entityName, err)
+      whisk.Debug(whisk.DbgError, "client.Packages.Delete(%s) failed: %s\n", qualifiedName.entityName, err)
       errStr := wski18n.T(
         "Unable to delete package '{{.name}}': {{.err}}",
         map[string]interface{}{
-          "name": qName.entityName,
+          "name": qualifiedName.entityName,
           "err": err,
         })
       werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
@@ -393,7 +365,7 @@ var packageDeleteCmd = &cobra.Command{
 
     fmt.Fprintf(color.Output,
       wski18n.T("{{.ok}} deleted package {{.name}}\n",
-        map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qName.entityName)}))
+        map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qualifiedName.entityName)}))
     return nil
   },
 }
@@ -407,30 +379,23 @@ var packageListCmd = &cobra.Command{
   RunE: func(cmd *cobra.Command, args []string) error {
     var err error
     var shared bool
+    var qualifiedName QualifiedName
+
+    if whiskErr := checkArgs(args, 0, 1, "Package list",
+      wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil {
+      return whiskErr
+    }
 
-    qName := QualifiedName{}
     if len(args) == 1 {
-      qName, err = parseQualifiedName(args[0])
-      if err != nil {
-        whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-        errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-            map[string]interface{}{"name": args[0], "err": err})
-        werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-          whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-        return werr
+      if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+        return parseQualifiedNameError(args[0], err)
       }
-      ns := qName.namespace
-      if len(ns) == 0 {
-        whisk.Debug(whisk.DbgError, "An empty namespace in the package name '%s' is invalid \n", args[0])
-        errStr := wski18n.T("No valid namespace detected. Run 'wsk property set --namespace' or ensure the name argument is preceded by a \"/\"")
-        werr := whisk.MakeWskError(errors.New(errStr), whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
-        return werr
+
+      if len(qualifiedName.entityName) > 0 {
+        return entityNameError(qualifiedName.entityName)
       }
 
-      client.Namespace = ns
-    } else if whiskErr := checkArgs(args, 0, 1, "Package list",
-        wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil {
-      return whiskErr
+      client.Namespace = qualifiedName.namespace
     }
 
     if Flags.common.shared == "yes" {
@@ -467,30 +432,27 @@ var packageRefreshCmd = &cobra.Command{
   PreRunE:       setupClientConfig,
   RunE: func(cmd *cobra.Command, args []string) error {
     var err error
-    var qName QualifiedName
+    var qualifiedName QualifiedName
 
     if whiskErr := checkArgs(args, 0, 1, "Package refresh",
         wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil {
       return whiskErr
+    }
+
+    if len(args) == 0 {
+      qualifiedName.namespace = getNamespace()
     } else {
-      if len(args) == 0 {
-        qName.namespace = getNamespace()
-      } else {
-        qName, err = parseQualifiedName(args[0])
-
-        if err != nil {
-          whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-          errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-              map[string]interface{}{"name": args[0], "err": err})
-          werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-            whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-          return werr
-        }
+      if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+        return parseQualifiedNameError(args[0], err)
+      }
+
+      if len(qualifiedName.entityName) > 0 {
+        return entityNameError(qualifiedName.entityName)
       }
     }
 
     currentNamespace := client.Config.Namespace
-    client.Config.Namespace = qName.namespace
+    client.Config.Namespace = qualifiedName.namespace
 
     defer func() {
       client.Config.Namespace = currentNamespace
diff --git a/commands/rule.go b/commands/rule.go
index 14bf64b..bc9ee1d 100644
--- a/commands/rule.go
+++ b/commands/rule.go
@@ -42,23 +42,18 @@ var ruleEnableCmd = &cobra.Command{
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 1, 1, "Rule enable", wski18n.T("A rule name is required.")); whiskErr != nil {
             return whiskErr
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-            return werr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
-        ruleName := qName.entityName
+        client.Namespace = qualifiedName.namespace
+        ruleName := qualifiedName.entityName
 
         _, _, err = client.Rules.SetState(ruleName, "active")
         if err != nil {
@@ -84,23 +79,18 @@ var ruleDisableCmd = &cobra.Command{
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 1, 1, "Rule disable", wski18n.T("A rule name is required.")); whiskErr != nil {
             return whiskErr
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-            return werr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
-        ruleName := qName.entityName
+        client.Namespace = qualifiedName.namespace
+        ruleName := qualifiedName.entityName
 
         _, _, err = client.Rules.SetState(ruleName, "inactive")
         if err != nil {
@@ -126,23 +116,18 @@ var ruleStatusCmd = &cobra.Command{
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 1, 1, "Rule status", wski18n.T("A rule name is required.")); whiskErr != nil {
             return whiskErr
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-            return werr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
-        ruleName := qName.entityName
+        client.Namespace = qualifiedName.namespace
+        ruleName := qualifiedName.entityName
 
         rule, _, err := client.Rules.Get(ruleName)
         if err != nil {
@@ -168,24 +153,19 @@ var ruleCreateCmd = &cobra.Command{
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 3, 3, "Rule create",
                 wski18n.T("A rule, trigger and action name are required.")); whiskErr != nil {
             return whiskErr
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-            return werr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
-        ruleName := qName.entityName
+        client.Namespace = qualifiedName.namespace
+        ruleName := qualifiedName.entityName
         triggerName := getQualifiedName(args[1], Properties.Namespace)
         actionName := getQualifiedName(args[2], Properties.Namespace)
 
@@ -222,24 +202,19 @@ var ruleUpdateCmd = &cobra.Command{
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 3, 3, "Rule update",
                 wski18n.T("A rule, trigger and action name are required.")); whiskErr != nil {
             return whiskErr
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-            return werr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
-        ruleName := qName.entityName
+        client.Namespace = qualifiedName.namespace
+        ruleName := qualifiedName.entityName
         triggerName := getQualifiedName(args[1], Properties.Namespace)
         actionName := getQualifiedName(args[2], Properties.Namespace)
 
@@ -274,6 +249,7 @@ var ruleGetCmd = &cobra.Command{
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
         var field string
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 1, 2, "Rule get", wski18n.T("A rule name is required.")); whiskErr != nil {
             return whiskErr
@@ -290,18 +266,12 @@ var ruleGetCmd = &cobra.Command{
             }
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-            return werr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
-        ruleName := qName.entityName
+        client.Namespace = qualifiedName.namespace
+        ruleName := qualifiedName.entityName
 
         rule, _, err := client.Rules.Get(ruleName)
         if err != nil {
@@ -339,23 +309,18 @@ var ruleDeleteCmd = &cobra.Command{
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 1, 1, "Rule delete", wski18n.T("A rule name is required.")); whiskErr != nil {
             return whiskErr
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            werr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-            return werr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
-        ruleName := qName.entityName
+        client.Namespace = qualifiedName.namespace
+        ruleName := qualifiedName.entityName
 
         if Flags.rule.disable {
             _, _, err := client.Rules.SetState(ruleName, "inactive")
@@ -392,28 +357,23 @@ var ruleListCmd = &cobra.Command{
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
-        qName := QualifiedName{}
+        var qualifiedName QualifiedName
+
+        if whiskErr := checkArgs(args, 0, 1, "Rule list",
+            wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil {
+            return whiskErr
+        }
 
         if len(args) == 1 {
-            qName, err = parseQualifiedName(args[0])
-            if err != nil {
-                whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-                errStr := wski18n.T("Namespace '{{.name}}' is invalid: {{.err}}\n",
-                        map[string]interface{}{"name": args[0], "err": err})
-                werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-                return werr
+            if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+                return parseQualifiedNameError(args[0], err)
             }
-            ns := qName.namespace
-            if len(ns) == 0 {
-                whisk.Debug(whisk.DbgError, "Namespace is missing from '%s'\n", args[0])
-                errStr := wski18n.T("No valid namespace detected. Run 'wsk property set --namespace' or ensure the name argument is preceded by a \"/\"")
-                werr := whisk.MakeWskError(errors.New(errStr), whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
-                return werr
+
+            if len(qualifiedName.entityName) > 0 {
+                return entityNameError(qualifiedName.entityName)
             }
-            client.Namespace = ns
-        } else if whiskErr := checkArgs(args, 0, 1, "Rule list",
-                wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil {
-            return whiskErr
+
+            client.Namespace = qualifiedName.namespace
         }
 
         ruleListOptions := &whisk.RuleListOptions{
diff --git a/commands/shared.go b/commands/shared.go
new file mode 100644
index 0000000..33cf01b
--- /dev/null
+++ b/commands/shared.go
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2015-2016 IBM Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package commands
+
+import (
+    "errors"
+
+    "../wski18n"
+    "../../go-whisk/whisk"
+)
+
+func entityNameError(entityName string) (error) {
+    errMsg := wski18n.T(
+        "An entity name, '{{.name}}', was provided instead of a namespace. Valid namespaces are of the following format: /NAMESPACE.",
+        map[string]interface{}{
+            "name": entityName,
+        })
+
+    return whisk.MakeWskError(errors.New(errMsg), whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
+}
+
+func parseQualifiedNameError(entityName string, err error) (error) {
+    whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", entityName, err)
+
+    errMsg := wski18n.T(
+        "'{{.name}}' is not a valid qualified name: {{.err}}",
+        map[string]interface{}{
+            "name": entityName,
+            "err": err,
+        })
+
+    return whisk.MakeWskError(errors.New(errMsg), whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
+}
diff --git a/commands/trigger.go b/commands/trigger.go
index 7b65e8c..3480656 100644
--- a/commands/trigger.go
+++ b/commands/trigger.go
@@ -49,24 +49,18 @@ var triggerFireCmd = &cobra.Command{
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
         var parameters interface{}
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 1, 2, "Trigger fire",
                 wski18n.T("A trigger name is required. A payload is optional.")); whiskErr != nil {
             return whiskErr
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-
-            return whiskErr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
+        client.Namespace = qualifiedName.namespace
 
         // Add payload to parameters
         if len(args) == 2 {
@@ -86,11 +80,11 @@ var triggerFireCmd = &cobra.Command{
             }
         }
 
-        trigResp, _, err := client.Triggers.Fire(qName.entityName, parameters)
+        trigResp, _, err := client.Triggers.Fire(qualifiedName.entityName, parameters)
         if err != nil {
-            whisk.Debug(whisk.DbgError, "client.Triggers.Fire(%s, %#v) failed: %s\n", qName.entityName, parameters, err)
+            whisk.Debug(whisk.DbgError, "client.Triggers.Fire(%s, %#v) failed: %s\n", qualifiedName.entityName, parameters, err)
             errStr := wski18n.T("Unable to fire trigger '{{.name}}': {{.err}}",
-                    map[string]interface{}{"name": qName.entityName, "err": err})
+                    map[string]interface{}{"name": qualifiedName.entityName, "err": err})
             werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL,
                 whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
             return werr
@@ -100,8 +94,8 @@ var triggerFireCmd = &cobra.Command{
             wski18n.T("{{.ok}} triggered /{{.namespace}}/{{.name}} with id {{.id}}\n",
                 map[string]interface{}{
                     "ok": color.GreenString("ok:"),
-                    "namespace": boldString(qName.namespace),
-                    "name": boldString(qName.entityName),
+                    "namespace": boldString(qualifiedName.namespace),
+                    "name": boldString(qualifiedName.entityName),
                     "id": boldString(trigResp.ActivationId)}))
         return nil
     },
@@ -117,46 +111,31 @@ var triggerCreateCmd = &cobra.Command{
         var err error
         var annotations interface{}
         var feedArgPassed bool = (Flags.common.feed != "")
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 1, 1, "Trigger create",
                 wski18n.T("A trigger name is required.")); whiskErr != nil {
             return whiskErr
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-            return whiskErr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
+        client.Namespace = qualifiedName.namespace
 
         var fullTriggerName string
         var fullFeedName string
+        var feedQualifiedName QualifiedName
         if feedArgPassed {
             whisk.Debug(whisk.DbgInfo, "Trigger has a feed\n")
-            feedqName, err := parseQualifiedName(Flags.common.feed)
-            if err != nil {
-                whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", Flags.common.feed, err)
-                errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                        map[string]interface{}{"name": Flags.common.feed, "err": err})
-                whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                    whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
-                return whiskErr
-            }
-            if len(feedqName.namespace) == 0 {
-                whisk.Debug(whisk.DbgError, "Namespace is missing from '%s'\n", Flags.common.feed)
-                errStr := wski18n.T("No valid namespace detected. Run 'wsk property set --namespace' or ensure the name argument is preceded by a \"/\"")
-                werr := whisk.MakeWskError(errors.New(errStr), whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
-                return werr
+
+            if feedQualifiedName, err = parseQualifiedName(Flags.common.feed); err != nil {
+                return parseQualifiedNameError(Flags.common.feed, err)
             }
 
-            fullFeedName = fmt.Sprintf("/%s/%s", feedqName.namespace, feedqName.entityName)
-            fullTriggerName = fmt.Sprintf("/%s/%s", qName.namespace, qName.entityName)
+            fullFeedName = fmt.Sprintf("/%s/%s", feedQualifiedName.namespace, feedQualifiedName.entityName)
+            fullTriggerName = fmt.Sprintf("/%s/%s", qualifiedName.namespace, qualifiedName.entityName)
             Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_LIFECYCLE_EVENT, FEED_CREATE))
             Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_TRIGGER_NAME, fullTriggerName))
             Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_AUTH_KEY, client.Config.AuthToken))
@@ -194,7 +173,7 @@ var triggerCreateCmd = &cobra.Command{
         }
 
         trigger := &whisk.Trigger{
-            Name:        qName.entityName,
+            Name:        qualifiedName.entityName,
             Annotations: annotations.(whisk.KeyValueArr),
         }
 
@@ -245,24 +224,18 @@ var triggerUpdateCmd = &cobra.Command{
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 1, 1, "Trigger update",
                 wski18n.T("A trigger name is required.")); whiskErr != nil {
             return whiskErr
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-
-            return whiskErr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
+        client.Namespace = qualifiedName.namespace
 
         // Convert the trigger's list of default parameters from a string into []KeyValue
         // The 1 or more --param arguments have all been combined into a single []string
@@ -291,7 +264,7 @@ var triggerUpdateCmd = &cobra.Command{
         }
 
         trigger := &whisk.Trigger{
-            Name:        qName.entityName,
+            Name:        qualifiedName.entityName,
             Parameters:  parameters.(whisk.KeyValueArr),
             Annotations: annotations.(whisk.KeyValueArr),
         }
@@ -321,6 +294,7 @@ var triggerGetCmd = &cobra.Command{
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
         var field string
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 1, 2, "Trigger get", wski18n.T("A trigger name is required.")); whiskErr != nil {
             return whiskErr
@@ -337,24 +311,17 @@ var triggerGetCmd = &cobra.Command{
             }
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-
-            return whiskErr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
+        client.Namespace = qualifiedName.namespace
 
-        retTrigger, _, err := client.Triggers.Get(qName.entityName)
+        retTrigger, _, err := client.Triggers.Get(qualifiedName.entityName)
         if err != nil {
-            whisk.Debug(whisk.DbgError, "client.Triggers.Get(%s) failed: %s\n", qName.entityName, err)
+            whisk.Debug(whisk.DbgError, "client.Triggers.Get(%s) failed: %s\n", qualifiedName.entityName, err)
             errStr := wski18n.T("Unable to get trigger '{{.name}}': {{.err}}",
-                    map[string]interface{}{"name": qName.entityName, "err": err})
+                    map[string]interface{}{"name": qualifiedName.entityName, "err": err})
             werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
             return werr
         }
@@ -364,12 +331,12 @@ var triggerGetCmd = &cobra.Command{
         } else {
             if len(field) > 0 {
                 fmt.Fprintf(color.Output, wski18n.T("{{.ok}} got trigger {{.name}}, displaying field {{.field}}\n",
-                    map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qName.entityName),
+                    map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qualifiedName.entityName),
                     "field": boldString(field)}))
                 printField(retTrigger, field)
             } else {
                 fmt.Fprintf(color.Output, wski18n.T("{{.ok}} got trigger {{.name}}\n",
-                        map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qName.entityName)}))
+                        map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qualifiedName.entityName)}))
                 printJSON(retTrigger)
             }
         }
@@ -389,30 +356,24 @@ var triggerDeleteCmd = &cobra.Command{
         var retTrigger *whisk.Trigger
         var fullFeedName string
         var origParams []string
+        var qualifiedName QualifiedName
 
         if whiskErr := checkArgs(args, 1, 1, "Trigger delete",
                 wski18n.T("A trigger name is required.")); whiskErr != nil {
             return whiskErr
         }
 
-        qName, err := parseQualifiedName(args[0])
-        if err != nil {
-            whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-            errMsg := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                    map[string]interface{}{"name": args[0], "err": err})
-            whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL,
-                whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
-
-            return whiskErr
+        if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+            return parseQualifiedNameError(args[0], err)
         }
 
-        client.Namespace = qName.namespace
+        client.Namespace = qualifiedName.namespace
 
-        retTrigger, _, err = client.Triggers.Get(qName.entityName)
+        retTrigger, _, err = client.Triggers.Get(qualifiedName.entityName)
         if err != nil {
-            whisk.Debug(whisk.DbgError, "client.Triggers.Get(%s) failed: %s\n", qName.entityName, err)
+            whisk.Debug(whisk.DbgError, "client.Triggers.Get(%s) failed: %s\n", qualifiedName.entityName, err)
             errStr := wski18n.T("Unable to get trigger '{{.name}}': {{.err}}",
-                    map[string]interface{}{"name": qName.entityName, "err": err})
+                    map[string]interface{}{"name": qualifiedName.entityName, "err": err})
             werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
             return werr
         }
@@ -423,34 +384,34 @@ var triggerDeleteCmd = &cobra.Command{
 
             if len(fullFeedName) > 0 {
                 origParams = Flags.common.param
-                fullTriggerName := fmt.Sprintf("/%s/%s", qName.namespace, qName.entityName)
+                fullTriggerName := fmt.Sprintf("/%s/%s", qualifiedName.namespace, qualifiedName.entityName)
                 Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_LIFECYCLE_EVENT, FEED_DELETE))
                 Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_TRIGGER_NAME, fullTriggerName))
                 Flags.common.param = append(Flags.common.param, getFormattedJSON(FEED_AUTH_KEY, client.Config.AuthToken))
 
-                err = configureFeed(qName.entityName, fullFeedName)
+                err = configureFeed(qualifiedName.entityName, fullFeedName)
                 if err != nil {
-                    whisk.Debug(whisk.DbgError, "configureFeed(%s, %s) failed: %s\n", qName.entityName, fullFeedName, err)
+                    whisk.Debug(whisk.DbgError, "configureFeed(%s, %s) failed: %s\n", qualifiedName.entityName, fullFeedName, err)
                 }
 
                 Flags.common.param = origParams
-                client.Namespace = qName.namespace
+                client.Namespace = qualifiedName.namespace
             }
 
         }
 
-        retTrigger, _, err = client.Triggers.Delete(qName.entityName)
+        retTrigger, _, err = client.Triggers.Delete(qualifiedName.entityName)
         if err != nil {
-            whisk.Debug(whisk.DbgError, "client.Triggers.Delete(%s) failed: %s\n", qName.entityName, err)
+            whisk.Debug(whisk.DbgError, "client.Triggers.Delete(%s) failed: %s\n", qualifiedName.entityName, err)
             errStr := wski18n.T("Unable to delete trigger '{{.name}}': {{.err}}",
-                map[string]interface{}{"name": qName.entityName, "err": err})
+                map[string]interface{}{"name": qualifiedName.entityName, "err": err})
             werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
             return werr
         }
 
         fmt.Fprintf(color.Output,
             wski18n.T("{{.ok}} deleted trigger {{.name}}\n",
-                map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qName.entityName)}))
+                map[string]interface{}{"ok": color.GreenString("ok:"), "name": boldString(qualifiedName.entityName)}))
 
         return nil
     },
@@ -464,28 +425,23 @@ var triggerListCmd = &cobra.Command{
     PreRunE: setupClientConfig,
     RunE: func(cmd *cobra.Command, args []string) error {
         var err error
-        qName := QualifiedName{}
+        var qualifiedName QualifiedName
+
+        if whiskErr := checkArgs(args, 0, 1, "Trigger list",
+            wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil {
+            return whiskErr
+        }
+
         if len(args) == 1 {
-            qName, err = parseQualifiedName(args[0])
-            if err != nil {
-                whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", args[0], err)
-                errStr := wski18n.T("'{{.name}}' is not a valid qualified name: {{.err}}",
-                        map[string]interface{}{"name": args[0], "err": err})
-                werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
-                return werr
+            if qualifiedName, err = parseQualifiedName(args[0]); err != nil {
+                return parseQualifiedNameError(args[0], err)
             }
-            ns := qName.namespace
-            if len(ns) == 0 {
-                whisk.Debug(whisk.DbgError, "Namespace is missing from '%s'\n", args[0])
-                errStr := wski18n.T("No valid namespace detected. Run 'wsk property set --namespace' or ensure the name argument is preceded by a \"/\"")
-                werr := whisk.MakeWskError(errors.New(errStr), whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
-                return werr
+
+            if len(qualifiedName.entityName) > 0 {
+                return entityNameError(qualifiedName.entityName)
             }
-            client.Namespace = ns
-            whisk.Debug(whisk.DbgInfo, "Using namespace '%s' from argument '%s''\n", ns, args[0])
-        } else if whiskErr := checkArgs(args, 0, 1, "Trigger list",
-                wski18n.T("An optional namespace is the only valid argument.")); whiskErr != nil {
-            return whiskErr
+
+            client.Namespace = qualifiedName.namespace
         }
 
         options := &whisk.TriggerListOptions{
diff --git a/commands/util.go b/commands/util.go
index 79af565..96e205a 100644
--- a/commands/util.go
+++ b/commands/util.go
@@ -49,16 +49,16 @@ type QualifiedName struct {
     entityName  string  // pkg+entity
 }
 
-func (qName QualifiedName) String() string {
+func (qualifiedName QualifiedName) String() string {
     output := []string{}
 
-    if len(qName.namespace) > 0 {
-        output = append(output, "/", qName.namespace, "/")
+    if len(qualifiedName.namespace) > 0 {
+        output = append(output, "/", qualifiedName.namespace, "/")
     }
-    if len(qName.packageName) > 0 {
-        output = append(output, qName.packageName, "/")
+    if len(qualifiedName.packageName) > 0 {
+        output = append(output, qualifiedName.packageName, "/")
     }
-    output = append(output, qName.entityName)
+    output = append(output, qualifiedName.entityName)
 
     return strings.Join(output, "")
 }
@@ -71,10 +71,10 @@ name, the namespace is also resolved from the property file.
 Return a qualifiedName struct
 
 Examples:
-      foo => qName {namespace: "_", entityName: foo}
-      pkg/foo => qName {namespace: "_", entityName: pkg/foo}
-      /ns/foo => qName {namespace: ns, entityName: foo}
-      /ns/pkg/foo => qName {namespace: ns, entityName: pkg/foo}
+      foo => qualifiedName {namespace: "_", entityName: foo}
+      pkg/foo => qualifiedName {namespace: "_", entityName: pkg/foo}
+      /ns/foo => qualifiedName {namespace: ns, entityName: foo}
+      /ns/pkg/foo => qualifiedName {namespace: ns, entityName: pkg/foo}
 */
 func parseQualifiedName(name string) (QualifiedName, error) {
     var qualifiedName QualifiedName
diff --git a/commands/wsk.go b/commands/wsk.go
index 236bf1c..48391e9 100644
--- a/commands/wsk.go
+++ b/commands/wsk.go
@@ -31,8 +31,14 @@ var WskCmd = &cobra.Command{
     PersistentPreRunE:parseConfigFlags,
 }
 
-
-
+var listCmd = &cobra.Command{
+    Use:   "list",
+    Short: wski18n.T("list entities in the current namespace"),
+    SilenceUsage:   true,
+    SilenceErrors:  true,
+    PreRunE: setupClientConfig,
+    RunE:   namespaceGetCmd.RunE,
+}
 
 func init() {
     WskCmd.SetHelpTemplate(`{{with or .Long .Short }}{{.}}
diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json
index 7a9b778..fd27946 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -832,8 +832,8 @@
     "translation": "{{.ok}} deleted action {{.name}}\n"
   },
   {
-    "id": "list all actions",
-    "translation": "list all actions"
+    "id": "list all actions in a namespace or actions contained in a package",
+    "translation": "list all actions in a namespace or actions contained in a package"
   },
   {
     "id": "Unable to obtain the list of actions for namespace '{{.name}}': {{.err}}",
@@ -1462,5 +1462,9 @@
   {
     "id": "Invalid format type: {{.type}}",
     "translation": "Invalid format type: {{.type}}"
+  },
+  {
+    "id": "An entity name, '{{.name}}', was provided instead of a namespace. Valid namespaces are of the following format: /NAMESPACE.",
+    "translation": "An entity name, '{{.name}}', was provided instead of a namespace. Valid namespaces are of the following format: /NAMESPACE."
   }
 ]

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

Mime
View raw message