CLI Commands
Varlock provides a command-line interface for managing environment variables and secrets. This reference documents all available CLI commands.
See installation for instructions on how to install Varlock.
Running commands in JS projects
Section titled “Running commands in JS projects”If you have installed varlock as a package.json dependency, rather than a standalone binary, the best way to invoke the CLI is via your package manager:
npm exec -- varlock ...yarn exec -- varlock ...pnpm exec -- varlock ...vlx -- varlock ...Also note that within package.json scripts, you can use it directly:
{ "scripts": { "start": "varlock run -- node app.js" }}Commands reference
Section titled “Commands reference”varlock init
Section titled “varlock init”Starts an interactive onboarding process to help you get started. Will help create your .env.schema and install varlock as a dependency if necessary.
varlock initvarlock load
Section titled “varlock load”Loads and validates environment variables according to your .env files, and prints the results. Default prints a nicely formatted, colorized summary of the results, but can also print out machine-readable formats.
Useful for debugging locally, and in CI to print out a summary of env vars.
varlock load [options]Options:
--format: Format of output [pretty|json|env]--show-all: Shows all items, not just failing ones, when validation is failing--env: Set the default environment flag (e.g.,--env production), only useful if not using@currentEnvin.env.schema
Examples:
# Load and validate environment variablesvarlock load
# Load and validate for a specific environment (when not using @currentEnv in .env.schema)varlock load --env production
# Output validation results in JSON formatvarlock load --format json
# When validation is failing, will show all items, rather than just failing onesvarlock load --show-allvarlock run
Section titled “varlock run”Executes a command in a child process, injecting your resolved and validated environment variables from your .env files. This is useful when a code-level integration is not possible.
varlock run -- <command>Examples:
varlock run -- node app.js # Run a Node.js applicationvarlock run -- python script.py # Run a Python scriptvarlock telemetry
Section titled “varlock telemetry”Opts in/out of anonymous usage analytics. This command creates/updates a configuration file at ~/.varlock/config.json saving your preference.
varlock telemetry disablevarlock telemetry enablevarlock help
Section titled “varlock help”Displays general help information, alias for varlock --help
varlock helpFor help about specific commands, use:
varlock subcommand --help