Skip to content

💻 Using the CLI

The Supersimple CLI offers convenient tools to validate & import your data models. To get started, you'll need an API token and the CLI itself. You can generate the token and install the CLI from your account settings page.

After installing the CLI, make sure to include it in your PATH. Here's an example to get you going, but your setup might require something more permanent (e.g. updating your ~/.profile, ~/.bashrc or similar config file)

sh
export PATH=$PATH:~/path/to/supersimple-cli

All commands require the following environment variables to be present (you can locate your account ID at the very top of your account settings page):

sh
export SUPERSIMPLE_TOKEN '<token>'
export SUPERSIMPLE_ACCOUNT_ID '<account_id>'
export SUPERSIMPLE_HOST 'https://app.supersimple.io'

Commands

For a list of available commands, the CLI's installed version, etc.

sh
supersimple --help

Each command also exposes their own --help option, for example

sh
supersimple import --help

Validating models

sh
supersimple validate config.yaml

If your models are split between multiple files, you can pass all of them to validation

sh
supersimple validate config_a.yaml config_b.yaml

If you remove any existing models from your configuration, they won't get automatically deleted from Supersimple. You can check if you have any such "dangling" models with the following flag. You can then delete them during import by passing a --delete-dangling flag (see below).

sh
supersimple validate config.yaml --validate-dangling

Importing

Use the Supersimple API to upload a new version of your data models. Even though your configuration can be split into multiple files, they'll need to be imported all at once to validate their integrity and relations.

sh
supersimple import config.yaml # OK for a single-file setup

supersimple import config_a.yaml # bad
supersimple import config_a.yaml config_b.yaml # good

Dangling objects can be deleted automatically during import with the --delete-dangling flag

sh
supersimple import config.yaml --delete-dangling

Autofix

To detect missing relations between models, use the fix command.

sh
supersimple fix config.yaml

The output of the fix command can be printed as YAML:

sh
supersimple fix --format=yaml config.yaml

When feeling lucky, you can overwrite your configuration file in-place:

sh
supersimple fix --format=yaml config.yaml > tmp.$$; mv tmp.$$ config.yaml

Discovery

Our CLI enables you to generate models from a database schema

Postgres

sh
supersimple discover postgres models --url <DATABASE_URL> > supersimple.yaml

Optionally, you can specify Postgres database schema using --schema option.

BigQuery

List datasets:

sh
supersimple discover bigquery datasets \
  --credentials <path to credentials.json>

Discover models:

sh
supersimple discover bigquery models \
  --credentials <path to credentials.json> \
  --project <project> \
  --dataset <dataset> > supersimple.yaml