This is an automated email from the ASF dual-hosted git repository. dubeejw pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push: new 69c53aa Updating the way we print names in the Cli Fixes #1155 (#2462) 69c53aa is described below commit 69c53aaa648d8a19aa9f0fc9b02a0429343ca4f1 Author: Jesus Alva <ja...@us.ibm.com> AuthorDate: Thu Sep 21 11:01:33 2017 -0500 Updating the way we print names in the Cli Fixes #1155 (#2462) * Changes so that we are more consistent with quoting names that are not bolded when we print statements * Fixing up tests related to making quoting consistent in our CLI --- .../src/test/scala/system/basic/WskSdkTests.scala | 2 +- tools/cli/go-whisk-cli/commands/action.go | 2 +- tools/cli/go-whisk-cli/commands/activation.go | 4 +-- tools/cli/go-whisk-cli/commands/api.go | 29 ++++++++-------- tools/cli/go-whisk-cli/commands/package.go | 2 +- tools/cli/go-whisk-cli/commands/sdk.go | 14 ++++---- tools/cli/go-whisk-cli/commands/util.go | 2 +- .../go-whisk-cli/wski18n/resources/en_US.all.json | 40 +++++++++++----------- 8 files changed, 48 insertions(+), 47 deletions(-) diff --git a/tests/src/test/scala/system/basic/WskSdkTests.scala b/tests/src/test/scala/system/basic/WskSdkTests.scala index df550b8..3e7e3b2 100644 --- a/tests/src/test/scala/system/basic/WskSdkTests.scala +++ b/tests/src/test/scala/system/basic/WskSdkTests.scala @@ -95,7 +95,7 @@ class WskSdkTests extends TestHelpers with WskTestHelpers { dir.mkdir() should be(true) wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "iOS"), workingDir = dir).stdout should include( - "Downloaded OpenWhisk iOS starter app. Unzip OpenWhiskIOSStarterApp.zip and open the project in Xcode.") + "Downloaded OpenWhisk iOS starter app. Unzip 'OpenWhiskIOSStarterApp.zip' and open the project in Xcode.") val sdk = new File(dir, "OpenWhiskIOSStarterApp.zip") sdk.exists() should be(true) diff --git a/tools/cli/go-whisk-cli/commands/action.go b/tools/cli/go-whisk-cli/commands/action.go index 86b427b..55750e0 100644 --- a/tools/cli/go-whisk-cli/commands/action.go +++ b/tools/cli/go-whisk-cli/commands/action.go @@ -894,7 +894,7 @@ func isWebAction(client *whisk.Client, qname QualifiedName) (error) { err = whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXIT_CODE_ERR_NETWORK, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) } else { - err = errors.New(wski18n.T("Action '{{.name}}' is not a web action. Issue 'wsk action update {{.name}} --web true' to convert the action to a web action.", + err = errors.New(wski18n.T("Action '{{.name}}' is not a web action. Issue 'wsk action update \"{{.name}}\" --web true' to convert the action to a web action.", map[string]interface{}{"name": fullActionName})) if action.WebAction() { diff --git a/tools/cli/go-whisk-cli/commands/activation.go b/tools/cli/go-whisk-cli/commands/activation.go index 9021267..be0d60d 100644 --- a/tools/cli/go-whisk-cli/commands/activation.go +++ b/tools/cli/go-whisk-cli/commands/activation.go @@ -145,7 +145,7 @@ var activationGetCmd = &cobra.Command{ if flags.common.summary { fmt.Printf( - wski18n.T("activation result for /{{.namespace}}/{{.name}} ({{.status}} at {{.time}})\n", + wski18n.T("activation result for '/{{.namespace}}/{{.name}}' ({{.status}} at {{.time}})\n", map[string]interface{}{ "namespace": activation.Namespace, "name": activation.Name, @@ -377,7 +377,7 @@ var activationPollCmd = &cobra.Command{ continue } else { fmt.Printf( - wski18n.T("\nActivation: {{.name}} ({{.id}})\n", + wski18n.T("\nActivation: '{{.name}}' ({{.id}})\n", map[string]interface{}{"name": activation.Name, "id": activation.ActivationID})) printJSON(activation.Logs) reported[activation.ActivationID] = true diff --git a/tools/cli/go-whisk-cli/commands/api.go b/tools/cli/go-whisk-cli/commands/api.go index bd60492..c1aa062 100644 --- a/tools/cli/go-whisk-cli/commands/api.go +++ b/tools/cli/go-whisk-cli/commands/api.go @@ -53,7 +53,7 @@ var fmtString = "%-30s %7s %20s %s\n" func IsValidApiVerb(verb string) (error, bool) { // Is the API verb valid? if _, ok := whisk.ApiVerbs[strings.ToUpper(verb)]; !ok { - whisk.Debug(whisk.DbgError, "Invalid API verb: %s\n", verb) + whisk.Debug(whisk.DbgError, "Invalid API verb: '%s'\n", verb) errMsg := wski18n.T("'{{.verb}}' is not a valid API verb. Valid values are: {{.verbs}}", map[string]interface{}{ "verb": verb, @@ -67,7 +67,7 @@ func IsValidApiVerb(verb string) (error, bool) { func hasPathPrefix(path string) (error, bool) { if (! strings.HasPrefix(path, "/")) { - whisk.Debug(whisk.DbgError, "path does not begin with '/': %s\n", path) + whisk.Debug(whisk.DbgError, "path does not begin with '/': '%s'\n", path) errMsg := wski18n.T("'{{.path}}' must begin with '/'.", map[string]interface{}{ "path": path, @@ -98,15 +98,15 @@ func isValidRelpath(relpath string) (error, bool) { */ func getManagedUrl(api *whisk.RetApi, relpath string, operation string) (url string) { baseUrl := strings.TrimSuffix(api.BaseUrl, "/") - whisk.Debug(whisk.DbgInfo, "getManagedUrl: baseUrl = %s, relpath = %s, operation = %s\n", baseUrl, relpath, operation) + whisk.Debug(whisk.DbgInfo, "getManagedUrl: baseUrl = '%s', relpath = '%s', operation = '%s'\n", baseUrl, relpath, operation) for path, _ := range api.Swagger.Paths { - whisk.Debug(whisk.DbgInfo, "getManagedUrl: comparing api relpath: %s\n", path) + whisk.Debug(whisk.DbgInfo, "getManagedUrl: comparing api relpath: '%s'\n", path) if (path == relpath) { whisk.Debug(whisk.DbgInfo, "getManagedUrl: relpath matches '%s'\n", relpath) for op, _ := range api.Swagger.Paths[path] { whisk.Debug(whisk.DbgInfo, "getManagedUrl: comparing operation: '%s'\n", op) if (strings.ToLower(op) == strings.ToLower(operation)) { - whisk.Debug(whisk.DbgInfo, "getManagedUrl: operation matches: %s\n", operation) + whisk.Debug(whisk.DbgInfo, "getManagedUrl: operation matches: '%s'\n", operation) url = baseUrl+path } } @@ -207,9 +207,9 @@ var apiCreateCmd = &cobra.Command{ baseUrl := retApi.BaseUrl for path, _ := range retApi.Swagger.Paths { managedUrl := strings.TrimSuffix(baseUrl, "/")+path - whisk.Debug(whisk.DbgInfo, "Managed path: %s\n",managedUrl) + whisk.Debug(whisk.DbgInfo, "Managed path: '%s'\n",managedUrl) for op, opv := range retApi.Swagger.Paths[path] { - whisk.Debug(whisk.DbgInfo, "Path operation: %s\n", op) + whisk.Debug(whisk.DbgInfo, "Path operation: '%s'\n", op) var fqActionName string if (opv.XOpenWhisk == nil) { fqActionName = "" @@ -218,7 +218,8 @@ var apiCreateCmd = &cobra.Command{ } else { fqActionName = "/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.ActionName } - whisk.Debug(whisk.DbgInfo, "baseUrl %s Path %s Path obj %+v\n", baseUrl, path, opv) + + whisk.Debug(whisk.DbgInfo, "baseUrl '%s' Path '%s' Path obj %+v\n", baseUrl, path, opv) if len(fqActionName) > 0 { fmt.Fprintf(color.Output, wski18n.T("{{.ok}} created API {{.path}} {{.verb}} for action {{.name}}\n{{.fullpath}}\n", @@ -574,7 +575,7 @@ func genFilteredList(resultApi *whisk.RetApi, apiPath string, apiVerb string) [] basePath := resultApi.Swagger.BasePath if (resultApi.Swagger != nil && resultApi.Swagger.Paths != nil) { for path, _ := range resultApi.Swagger.Paths { - whisk.Debug(whisk.DbgInfo, "genFilteredList: comparing api relpath: %s\n", path) + whisk.Debug(whisk.DbgInfo, "genFilteredApi: comparing api relpath: '%s'\n", path) if ( len(apiPath) == 0 || path == apiPath) { whisk.Debug(whisk.DbgInfo, "genFilteredList: relpath matches\n") for op, opv := range resultApi.Swagger.Paths[path] { @@ -612,7 +613,7 @@ func genFilteredRow(resultApi *whisk.RetApi, apiPath string, apiVerb string, max basePath := resultApi.Swagger.BasePath if (resultApi.Swagger != nil && resultApi.Swagger.Paths != nil) { for path, _ := range resultApi.Swagger.Paths { - whisk.Debug(whisk.DbgInfo, "genFilteredRow: comparing api relpath: %s\n", path) + whisk.Debug(whisk.DbgInfo, "genFilteredRow: comparing api relpath: '%s'\n", path) if ( len(apiPath) == 0 || path == apiPath) { whisk.Debug(whisk.DbgInfo, "genFilteredRow: relpath matches\n") for op, opv := range resultApi.Swagger.Paths[path] { @@ -675,7 +676,7 @@ func getLargestActionNameSize(retApiArray *whisk.RetApiArray, apiPath string, ap var resultApi = retApiArray.Apis[i].ApiValue if (resultApi.Swagger != nil && resultApi.Swagger.Paths != nil) { for path, _ := range resultApi.Swagger.Paths { - whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: comparing api relpath: %s\n", path) + whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: comparing api relpath: '%s'\n", path) if ( len(apiPath) == 0 || path == apiPath) { whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: relpath matches\n") for op, opv := range resultApi.Swagger.Paths[path] { @@ -709,7 +710,7 @@ func getLargestApiNameSize(retApiArray *whisk.RetApiArray, apiPath string, apiVe apiName := resultApi.Swagger.Info.Title if (resultApi.Swagger != nil && resultApi.Swagger.Paths != nil) { for path, _ := range resultApi.Swagger.Paths { - whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: comparing api relpath: %s\n", path) + whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: comparing api relpath: '%s'\n", path) if ( len(apiPath) == 0 || path == apiPath) { whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: relpath matches\n") for op, opv := range resultApi.Swagger.Paths[path] { @@ -869,7 +870,7 @@ func parseSwaggerApi() (*whisk.Api, error) { swaggerObj := new(whisk.ApiSwagger) err = json.Unmarshal([]byte(swagger), swaggerObj) if ( err != nil ) { - whisk.Debug(whisk.DbgError, "JSON parse of `%s' error: %s\n", flags.api.configfile, err) + whisk.Debug(whisk.DbgError, "JSON parse of '%s' error: %s\n", flags.api.configfile, err) errMsg := wski18n.T("Error parsing swagger file '{{.name}}': {{.err}}", map[string]interface{}{"name": flags.api.configfile, "err": err}) whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXIT_CODE_ERR_GENERAL, @@ -925,7 +926,7 @@ func getUserContextId() (string, error) { if len(props["AUTH"]) > 0 { guid = strings.Split(props["AUTH"], ":")[0] } else { - whisk.Debug(whisk.DbgError, "AUTH property not set in properties file: %s\n", Properties.PropsFile) + whisk.Debug(whisk.DbgError, "AUTH property not set in properties file: '%s'\n", Properties.PropsFile) errStr := wski18n.T("Authorization key is not configured (--auth is required)") err = whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) } diff --git a/tools/cli/go-whisk-cli/commands/package.go b/tools/cli/go-whisk-cli/commands/package.go index 1696330..4f464c3 100644 --- a/tools/cli/go-whisk-cli/commands/package.go +++ b/tools/cli/go-whisk-cli/commands/package.go @@ -465,7 +465,7 @@ var packageRefreshCmd = &cobra.Command{ switch resp.StatusCode { case http.StatusOK: - fmt.Printf(wski18n.T("{{.name}} refreshed successfully\n", + fmt.Printf(wski18n.T("'{{.name}}' refreshed successfully\n", map[string]interface{}{"name": client.Config.Namespace})) fmt.Println(wski18n.T("created bindings:")) diff --git a/tools/cli/go-whisk-cli/commands/sdk.go b/tools/cli/go-whisk-cli/commands/sdk.go index 1abfbfd..ca9a42c 100644 --- a/tools/cli/go-whisk-cli/commands/sdk.go +++ b/tools/cli/go-whisk-cli/commands/sdk.go @@ -115,7 +115,7 @@ func dockerInstall() error { targetFile := sdkMap[SDK_DOCKER_COMPONENT_NAME].FileName if _, err = os.Stat(targetFile); err == nil { whisk.Debug(whisk.DbgError, "os.Stat reports file '%s' exists\n", targetFile) - errStr := wski18n.T("The file {{.name}} already exists. Delete it and retry.", + errStr := wski18n.T("The file '{{.name}}' already exists. Delete it and retry.", map[string]interface{}{"name": targetFile}) werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr @@ -145,7 +145,7 @@ func iOSInstall() error { } fmt.Printf( - wski18n.T("Downloaded OpenWhisk iOS starter app. Unzip {{.name}} and open the project in Xcode.\n", + wski18n.T("Downloaded OpenWhisk iOS starter app. Unzip '{{.name}}' and open the project in Xcode.\n", map[string]interface{}{"name": sdkMap[SDK_IOS_COMPONENT_NAME].FileName})) return nil } @@ -154,7 +154,7 @@ func sdkInstall(componentName string) error { targetFile := sdkMap[componentName].FileName if _, err := os.Stat(targetFile); err == nil { whisk.Debug(whisk.DbgError, "os.Stat reports file '%s' exists\n", targetFile) - errStr := wski18n.T("The file {{.name}} already exists. Delete it and retry.", + errStr := wski18n.T("The file '{{.name}}' already exists. Delete it and retry.", map[string]interface{}{"name": targetFile}) werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr @@ -181,7 +181,7 @@ func sdkInstall(componentName string) error { sdkfile, err := os.Create(targetFile) if err != nil { whisk.Debug(whisk.DbgError, "os.Create(%s) failure: %s\n", targetFile, err) - errStr := wski18n.T("Error creating SDK file {{.name}}: {{.err}}", + errStr := wski18n.T("Error creating SDK file '{{.name}}': {{.err}}", map[string]interface{}{"name": targetFile, "err": err}) werr := whisk.MakeWskErrorFromWskError(errors.New(errStr), err, whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr @@ -209,7 +209,7 @@ func sdkInstall(componentName string) error { targetdir := sdkMap[componentName].UnpackDir if _, err = os.Stat(targetdir); err == nil { whisk.Debug(whisk.DbgError, "os.Stat reports that directory '%s' exists\n", targetdir) - errStr := wski18n.T("The directory {{.name}} already exists. Delete it and retry.", + errStr := wski18n.T("The directory '{{.name}}' already exists. Delete it and retry.", map[string]interface{}{"name": targetdir}) werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr @@ -223,7 +223,7 @@ func sdkInstall(componentName string) error { err := unpackGzip(targetFile, "temp.tar") if err != nil { whisk.Debug(whisk.DbgError, "unpackGzip(%s,temp.tar) failure: %s\n", targetFile, err) - errStr := wski18n.T("Error unGzipping file {{.name}}: {{.err}}", + errStr := wski18n.T("Error unGzipping file '{{.name}}': {{.err}}", map[string]interface{}{"name": targetFile, "err": err}) werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr @@ -234,7 +234,7 @@ func sdkInstall(componentName string) error { err = unpackTar("temp.tar") if err != nil { whisk.Debug(whisk.DbgError, "unpackTar(temp.tar) failure: %s\n", err) - errStr := wski18n.T("Error untarring file {{.name}}: {{.err}}", + errStr := wski18n.T("Error untarring file '{{.name}}': {{.err}}", map[string]interface{}{"name": "temp.tar", "err": err}) werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr diff --git a/tools/cli/go-whisk-cli/commands/util.go b/tools/cli/go-whisk-cli/commands/util.go index fa16168..65b1c24 100644 --- a/tools/cli/go-whisk-cli/commands/util.go +++ b/tools/cli/go-whisk-cli/commands/util.go @@ -588,7 +588,7 @@ func unpackGzip(inpath string, outpath string) error { // Make sure the target file does not exist if _, err := os.Stat(outpath); err == nil { whisk.Debug(whisk.DbgError, "os.Stat reports file '%s' exists\n", outpath) - errStr := wski18n.T("The file {{.name}} already exists. Delete it and retry.", + errStr := wski18n.T("The file '{{.name}}' already exists. Delete it and retry.", map[string]interface{}{"name": outpath}) werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return werr diff --git a/tools/cli/go-whisk-cli/wski18n/resources/en_US.all.json b/tools/cli/go-whisk-cli/wski18n/resources/en_US.all.json index 5f5bdf8..3236830 100644 --- a/tools/cli/go-whisk-cli/wski18n/resources/en_US.all.json +++ b/tools/cli/go-whisk-cli/wski18n/resources/en_US.all.json @@ -184,8 +184,8 @@ "translation": "Package refresh for namespace '{{.name}}' failed: {{.err}}" }, { - "id": "{{.name}} refreshed successfully\n", - "translation": "{{.name}} refreshed successfully\n" + "id": "'{{.name}}' refreshed successfully\n", + "translation": "'{{.name}}' refreshed successfully\n" }, { "id": "created bindings:", @@ -566,8 +566,8 @@ "translation": "The SDK component argument '{{.component}}' is invalid. Valid components are docker, ios and bashauto" }, { - "id": "The file {{.name}} already exists. Delete it and retry.", - "translation": "The file {{.name}} already exists. Delete it and retry." + "id": "The file '{{.name}}' already exists. Delete it and retry.", + "translation": "The file '{{.name}}' already exists. Delete it and retry." }, { "id": "The {{.component}} SDK installation failed: {{.err}}", @@ -578,8 +578,8 @@ "translation": "The docker skeleton is now installed at the current directory." }, { - "id": "Downloaded OpenWhisk iOS starter app. Unzip {{.name}} and open the project in Xcode.\n", - "translation": "Downloaded OpenWhisk iOS starter app. Unzip {{.name}} and open the project in Xcode.\n" + "id": "Downloaded OpenWhisk iOS starter app. Unzip '{{.name}}' and open the project in Xcode.\n", + "translation": "Downloaded OpenWhisk iOS starter app. Unzip '{{.name}}' and open the project in Xcode.\n" }, { "id": "Unable to retrieve '{{.urlpath}}' SDK: {{.err}}", @@ -590,24 +590,24 @@ "translation": "Server failed to send the '{{.component}}' SDK: {{.err}}" }, { - "id": "Error creating SDK file {{.name}}: {{.err}}", - "translation": "Error creating SDK file {{.name}}: {{.err}}" + "id": "Error creating SDK file '{{.name}}': {{.err}}", + "translation": "Error creating SDK file '{{.name}}': {{.err}}" }, { "id": "Error copying server response into file: {{.err}}", "translation": "Error copying server response into file: {{.err}}" }, { - "id": "The directory {{.name}} already exists. Delete it and retry.", - "translation": "The directory {{.name}} already exists. Delete it and retry." + "id": "The directory '{{.name}}' already exists. Delete it and retry.", + "translation": "The directory '{{.name}}' already exists. Delete it and retry." }, { - "id": "Error unGzipping file {{.name}}: {{.err}}", - "translation": "Error unGzipping file {{.name}}: {{.err}}" + "id": "Error unGzipping file '{{.name}}': {{.err}}", + "translation": "Error unGzipping file '{{.name}}': {{.err}}" }, { - "id": "Error untarring file {{.name}}: {{.err}}", - "translation": "Error untarring file {{.name}}: {{.err}}" + "id": "Error untarring file '{{.name}}': {{.err}}", + "translation": "Error untarring file '{{.name}}': {{.err}}" }, { "id": "work with triggers", @@ -984,8 +984,8 @@ "translation": "Unable to get activation '{{.id}}': {{.err}}" }, { - "id": "activation result for /{{.namespace}}/{{.name}} ({{.status}} at {{.time}})\n", - "translation": "activation result for /{{.namespace}}/{{.name}} ({{.status}} at {{.time}})\n" + "id": "activation result for '/{{.namespace}}/{{.name}}' ({{.status}} at {{.time}})\n", + "translation": "activation result for '/{{.namespace}}/{{.name}}' ({{.status}} at {{.time}})\n" }, { "id": "{{.ok}} got activation {{.id}}\n", @@ -1028,8 +1028,8 @@ "translation": "Polling for activation logs\n" }, { - "id": "\nActivation: {{.name}} ({{.id}})\n", - "translation": "\nActivation: {{.name}} ({{.id}})\n" + "id": "\nActivation: '{{.name}}' ({{.id}})\n", + "translation": "\nActivation: '{{.name}}' ({{.id}})\n" }, { "id": "Activation list does not contain any activations.", @@ -1424,8 +1424,8 @@ "translation": "Invalid argument '{{.arg}}' for --web flag. Valid input consist of 'yes', 'true', 'raw', 'false', or 'no'." }, { - "id": "Action '{{.name}}' is not a web action. Issue 'wsk action update {{.name}} --web true' to convert the action to a web action.", - "translation": "Action '{{.name}}' is not a web action. Issue 'wsk action update {{.name}} --web true' to convert the action to a web action." + "id": "Action '{{.name}}' is not a web action. Issue 'wsk action update \"{{.name}}\" --web true' to convert the action to a web action.", + "translation": "Action '{{.name}}' is not a web action. Issue 'wsk action update \"{{.name}}\" --web true' to convert the action to a web action." }, { "id": "Invalid configuration. The x-openwhisk stanza is missing.", -- To stop receiving notification emails like this one, please contact ['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].