@ibmcloud/gp-js-cli
v1.0.1
Published
Command-line client for the IBM Cloud Globalization Pipeline Service
Downloads
3
Readme
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 [email protected]
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
true
Using 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
true
Usage
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.json
Credentials
See also the getClient()
API docs
Credentials may be passed in one of the following ways:
Via the
-j/--jsonCreds
option, which takes a path to a JSON file with credentials 2a. For GP Auth: the four individual options--serviceUrl
,--instanceId
,--user
, and--password
2b. for IAM auth via--iam_endpoint
and--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.json
See 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
,--password
See Credentials, above. These options specify the four credential parameters individually for GP Auth.
--iam_endpoint
,--apikey
See Credentials, above. These options specify the two credential parameters individually for IAM Auth.
-F json
|--outputFormat=json
This 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.json
Produce JSON output.
none
Don’t produce any output (besides errors).
line
Output 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
help
Print help
ping
Indicate whether the server is reachable or not.
info
Prints general info about the GP service
instanceInfo
Prints information specific to your service instance (such as usage)
Bundle Commands
list
Return a list of bundles
show -b mybundle
Show detailed information about
mybundle
create -b mybundle -l en,es,fr
Create bundle
mybundle
with source langen
and target languageses
andfr
. (The first language code is the source.)delete -b mybundle
Delete bundle
mybundle
update -b mybundle -l es,fr,mt
Update bundle
mybundle
to have target languageses
,fr
andmt
import -b mybundle -l en -f mybundle.json
Import
mybundle.json
to replace theen
language content for bundlemybundle
.For nested structure, use the
-T
option to flatten the keys using the g11n-pipeline-flatten component.export -b mybundle -l en -F json > mybundle.json
Export bundle
mybundle
to disk asmybundle.json
For nested structure, use the
-T
option to expand the keys using the g11n-pipeline-flatten component.
Translation Request Commands
trs
List the Translation Requests
docTrs
List 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.