Skip to content

Scripting the Airdress CLI

The CLI is built to be driven: one flag for machine-readable output, exit codes that mean one thing each, and no prompt a script cannot answer.

Every command takes --output json (or -o json). The result is JSON on stdout; a failure is exactly one JSON object on stderr, with a stable code to decide on (see exit codes). Under --output json the → acting on … status line is silent, and the resolved airdress travels inside the result.

Terminal window
airdress airdress list --output json | jq -r '.airdresses[].name'
airdress fn deploy ./hello --yes --output json
airdress current --output json # for a prompt: active profile, airdress, source

airdress airdress list --output json answers one object: the profile, its active_airdress, and the airdresses array.

Every command that changes something it cannot undo asks first, and every one of them takes -y / --yes. Without a terminal, or under --output json, it never asks: it exits 7 with confirmation_required and a hint naming --yes. A script therefore either passes --yes on purpose or fails loudly; it never hangs on a prompt.

Terminal window
airdress device revoke "$ENROLLMENT_ID" --dry-run # see what would go
airdress device revoke "$ENROLLMENT_ID" --yes # then do it

The connect timeout is 10 seconds. Each request has 30 seconds unless you say otherwise:

Terminal window
airdress --timeout 120 fn logs hello --since 1h
AIRDRESS_TIMEOUT=120 airdress fn logs hello --since 1h

A request that does not answer in time exits 5 with timeout.

Precedence: flag, then environment, then default

Section titled “Precedence: flag, then environment, then default”

Wherever a setting can come from more than one place, the command line wins over the environment, and the environment wins over the default (or the profile). --timeout 60 beats AIRDRESS_TIMEOUT=10, which beats 30. -A office beats AIRDRESS_NAME=home, which beats the .airdress marker and the profile’s pinned airdress (the full order is in Get started).

Terminal window
TOKEN=$(airdress auth token) # for the hub's API
OP_TOKEN=$(airdress auth token --airdress home) # one that only that airdress accepts

auth token prints a fresh bearer token and nothing else, refreshing first when the cached one is stale. The output is a credential: do not log it, and treat anything that captured it as a reason to sign out and in again. Scripts should call this command rather than read the profile file.

VariableEffect
AIRDRESS_NAMEThe airdress to act on, below --airdress
AIRDRESS_QUIET1, true, yes or on: no → acting on … line
AIRDRESS_TIMEOUTPer-request timeout in seconds (default 30; --timeout wins)
AIRDRESS_LOG / RUST_LOGDiagnostic traces, instead of -v / -vv
AIRDRESS_OPERATOR_URLTalk to this airdress directly, skipping the hub lookup
AIRDRESS_MACHINE_KEY, AIRDRESS_MACHINE_ENROLLMENTAct as an approved machine (deploying from CI)
AIRDRESS_FUNCTION_SIGNING_KEYThe function source-signing seed, as hex
AIRDRESS_PLUGIN_INDEX_KEYSPinned registry keys for plugins verify
AIRDRESS_BOOTSTRAP_TOKENFor device bootstrap, instead of a flag
AIRDRESS_CA_FILETrust a private CA in addition to the system roots
AIRDRESS_INSECURESkip certificate validation. Development only; warns every time

Boolean variables take 1, true, yes or on, case-insensitive, so a typo does not quietly turn validation off.

For deploying functions from a pipeline, the CLI authenticates as an approved machine rather than as you; see Functions: deploying from CI. The public GitHub Action airdress-co/deploy-functions wraps that mode.