Overview
The Ditto CLI allows developers to access the Ditto API directly from the command line. The Ditto CLI updates text directly in local development. Teams can also build workflows with the CLI, including utilizing it in CI/CD.Installation
To install the CLI as a development dependency:Note: npx comes with
npm
5.2 or higherAuthentication
The first time you run the CLI, you’ll be asked to provide an API key. You can generate an API key in your developer integrations settings.Using an env variable for your API key
Using an env variable for your API key
By default, your API key is saved to
$HOME/.config/ditto
; the default path can be overwritten by specifying a custom one via the environment variable DITTO_CONFIG_FILE
.The Ditto API key is read from the file at the path stored at DITTO_CONFIG_FILE
unless it’s explicitly provided by the env var DITTO_API_KEY
.Updating your API key
Updating your API key
We don’t recommend editing the authentication file by hand; if you need to remove a saved API key or swap one key with another, it’s better to fully delete the file and then re-run the CLI.To change your API key, delete the
$HOME/.config/ditto
file and you’ll be prompted for a new key the next time that the CLI executes.Fetching text
Once you’ve installed, authenticated, and configured the CLI, you’ll be able to pull down up-to-date text by running the CLI:/ditto
directory from where you’re running the CLI. (For more information on the structure of files pulled by Ditto, see files)
Because the Ditto CLI updates your string files locally, you can continue to manage it as you would with any other product update (push it to staging, commit changes to a branch, etc.).
By default, the pull command will look for a config file in ./ditto/config.yml
. To use a config file from a different location, provide the path via -c
or --config
flag: