Config Modes

View as Markdown

hsql reads the same config files as Harlequin, and Configuring Harlequin covers them: where they are found, how to write one, and how a profile is selected. -P NAME, -P None and --config-path PATH mean the same thing to hsql that they mean to the IDE.

What hsql adds is five modes that work on those files instead of running SQL. None of them connects to a database.

hsql --config list-profiles
hsql --config show
hsql --config show --json
hsql --config validate
hsql --config schema
hsql --config init -P prod -a sqlite ./app.db --read-only --limit -1

list-profiles

The names -P takes, each one’s adapter, and which one is the default.

show

The merged config, with the file each value came from beside it. --json for a parser. Values an adapter declares as secret are masked here, as they are everywhere else hsql prints them.

validate

Every problem in every discovered file, exiting 2 if it found any. It names the file and the key, including a misspelled key an adapter would otherwise ignore, and an environment variable a ${VAR} needs and does not have.

Two commands are the whole check that a profile works:

hsql --config validate
hsql -P prod --catalog

schema

A JSON Schema for a config file, covering the adapters installed here.

lightbulb icon Tip

Point an editor at it for completion as you type: hsql --config schema -o ./schema.json. The published copy, which generated config files already name, is at harlequin.sh/schemas/config/v1.json.

init

Writes a profile from the options passed — hsql’s and the adapter’s alike — into the nearest config file:

hsql --config init -P prod -a postgres --host db.example.com --read-only

It prompts for nothing, and leaves other profiles and the file’s comments untouched, so it is the mode for a script or an agent. harlequin --config is the interactive wizard.

Output

list-profiles and validate are result sets, so every format and output option applies:

hsql --config list-profiles --csv
hsql --config validate -tA

Like --catalog, these are modes rather than options: passing -c or -f beside one exits 2.