@ibmcloud/gp-js-cli v1.0.1
Globalization Pipeline CLI for JavaScript
The GP Command Line Interface is modelled somewhat on the GP Java CLI. This CLI was part of the g11n-pipeline package prior to g11n-pipeline@4.x
Installation
You can use the GP CLI to perform some operations from the commandline.
$ npm install -g @ibmcloud/gp-js-cli
$ gp-js-cli -j gpconfig.json ping
trueUsing npx you do not even need to install @ibmcloud/gp-js-cli to run a one-off command.
$ npx @ibmcloud/gp-js-cli -j gpconfig.json ping
trueUsage
The CLI takes one 'verb' (action) which can appear anywhere in the command line. Options have a short or a long form. Therefore, the following are all equivalent.
g11n-pipeline -j gpconfig.json ping
g11n-pipeline ping -j gpconfig.json
g11n-pipeline --jsonCredentials=gpconfig.json ping
g11n-pipeline ping --jsonCredentials=gpconfig.jsonCredentials
See also the getClient() API docs
Credentials may be passed in one of the following ways:
- Via the
-j/--jsonCredsoption, which takes a path to a JSON file with credentials 2a. For GP Auth: the four individual options--serviceUrl,--instanceId,--user, and--password2b. for IAM auth via--iam_endpointand--apikey By the following environment variables:
- GP_URL: Service URL (e.g. https://gp-rest.ng.bluemix.net/translate/rest)
- GP_INSTANCE_ID: Service instance ID (e.g. d3f537cd617f34c86ac6b270f3065e73)
if using GP Authentication:
- GP_USER_ID: User ID (e.g. e92a1282a0e4f97bec93aa9f56fdb838)
- GP_PASSWORD: User password (e.g. zg5SlD+ftXYRIZDblLgEA/ILkkCNqE1y)
if using IAM Authentication:
- GP_IAM_API_KEY: IAM API Key
- GP_IAM_ENDPOINT: IAM endpoint (e.g. https://iam.cloud.ibm.com)
Common Options
-j file.json|--jsonCredentials=file.jsonSee Credentials, above.
This option specifies a credentials file containing the GP credentials. This is a JSON file with any of the following formats:
{"url":"≈", "instanceId":"≈", "userId":"≈", "password":"≈"}{"credentials": {"url":"≈", "instanceId":"≈", "userId":"≈", "password":"≈"}}{"url":"≈", "instanceId":"≈", "iam_endpoint":"≈", "apikey":"≈"}{"credentials": {"url":"≈", "instanceId":"≈", "iam_endpoint":"≈", "apikey":"≈"}}--serviceUrl,--instanceId,--user,--passwordSee Credentials, above. These options specify the four credential parameters individually for GP Auth.
--iam_endpoint,--apikeySee Credentials, above. These options specify the two credential parameters individually for IAM Auth.
-F json|--outputFormat=jsonThis option specifies the eventual output format of the results of the CLI operation. (API note: This formatting is applied by the
filter()function.run()does not interpret this option.)Possible formats:
compact(default)This format causes
console.dir()to be used for output. It is more compact than JSON.jsonProduce JSON output.
noneDon’t produce any output (besides errors).
lineOutput in line-by-line mode, which could be useful for processing without parsing JSON:
For operations that return an array (such as
list), output the array one element per line.For operations that return an object (such as
trs), outputs the keys one element per line.
Verbs
General Commands
helpPrint help
pingIndicate whether the server is reachable or not.
infoPrints general info about the GP service
instanceInfoPrints information specific to your service instance (such as usage)
Bundle Commands
listReturn a list of bundles
show -b mybundleShow detailed information about
mybundlecreate -b mybundle -l en,es,frCreate bundle
mybundlewith source langenand target languagesesandfr. (The first language code is the source.)delete -b mybundleDelete bundle
mybundleupdate -b mybundle -l es,fr,mtUpdate bundle
mybundleto have target languageses,frandmtimport -b mybundle -l en -f mybundle.jsonImport
mybundle.jsonto replace theenlanguage content for bundlemybundle.For nested structure, use the
-Toption to flatten the keys using the g11n-pipeline-flatten component.export -b mybundle -l en -F json > mybundle.jsonExport bundle
mybundleto disk asmybundle.jsonFor nested structure, use the
-Toption to expand the keys using the g11n-pipeline-flatten component.
Translation Request Commands
trsList the Translation Requests
docTrsList the Document Translation Requests
API
The Command Line may be called from your own application code. The run() function
returns a promise containing the output content. See API.md#Cli
// from a script (parse args)
const Cli = require('g11n-pipeline/lib/gpcli');
new Cli(Cli.parseArgs(process.argv)).run().then(…)You can also preload the arguments:
const Cli = require('g11n-pipeline/lib/gpcli');
new Cli({_:['list'],jsonCreds:'creds.json'}).run().then((r) => console.dir(r));Community
- View or file GitHub Issues
- Connect with the open source community on developerWorks Open
Contributing
See CONTRIBUTING.md.
License
Apache 2.0. See LICENSE.txt
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.