Commands
The command reference of the Trajectonomics CLI.
traj has 14 top-level commands. Six are groups with their own subcommands — account, baseline,
projection, report, scenario and tx — and the other eight are single commands. traj help
lists them and traj help <command> shows one command’s usage; both are generated from the same
definitions that validate input, so the two cannot drift
(ADR 0015).
The command tree
| Command | What it does |
|---|---|
| account | Manage the chart of accounts |
| balance | Show every account’s balance and net worth at a date |
| baseline | Show the Baseline a Projection starts from |
| export | Write the stored rows into a new directory |
| fi | Report the financial independence date under a Scenario |
| help | Show usage for traj or for one command |
| init | Create the data directory and an empty database |
| inspect | Show the stored rows of one table, or of every table |
| projection | Project the future under a Scenario, and compare two of them |
| report | Report on the ledger over a period or at a date |
| scenario | Manage Scenarios, the named what-ifs |
| schema | Describe the commands and the error registry |
| tx | Manage ledger transactions |
| version | Print the CLI version |
A group needs a subcommand: traj tx on its own is invalid input (exit code 2), and the message
names the command that lists its subcommands, traj help tx.
Global options
Every command accepts:
--json— print JSON; errors become a JSON envelope on stderr.-h,--help— show usage.-v,--version— print the version.
A bare -- ends flag parsing: nothing after it counts as a flag.
Exit codes
0 ok, 1 unexpected, 2 invalid input, 3 domain rejection, 4 not found, 5 conflict
(ADR 0010).
Errors
In JSON mode a failure is a JSON envelope on stderr, where code names the failure and exitCode
names its class; both come from one registry that traj schema prints
(ADR 0013):
{"error":{"code":"not_found","exitCode":4,"message":"The requested resource was not found."}} Outside JSON mode the same failure is text on stderr with the same exit code. Commands never prompt.
Document input
Some commands take a JSON document beside the flag form — --postings on tx add and tx amend,
--file on scenario apply — named by a path, or - to read it from stdin
(ADR 0020).
The transaction document those --postings flags read is on
the tx page.
Decisions
- ADR 0010: explicit output format, JSON error envelope, fixed exit codes
- ADR 0013: the error envelope names its own exit class
- ADR 0015: commands form a tree, flags come from the input schema
- ADR 0020: a leaf may declare a document schema, and
-reads it from stdin
Source: trajectonomics/cli.