Command reference

Everything the browser app does that can be scripted, and more.

Run it as vendor/bin/barntree. Every command that reads or changes a barn finds it from any folder inside it, says which barn it is using, and refuses outside one.

Commands #

CommandWhat it does
initMakes a barn here if there is none, and says where the Templates live.
skills:installCopies Barntree’s agent skills into the project.
checkReads every Template and reports any that break a rule.
export TEMPLATE [--as=KIND] [--to=PATH]Shows a Template as text, markdown, folders or a mermaid diagram.
guiStarts the browser app, when barntree-gui is installed.
template:list, template:show, template:historyRead Templates and their revisions.
template:create, template:copy, template:edit, template:apply, template:deleteMake, copy, change and delete Templates.
type:showReads one type and where it is used.
type:create, type:edit, type:deleteMake, change and delete types.
map:add-child, map:remove-child, list:set-member-typeConnect types to each other.
construction:list, construction:show, construction:historyRead Constructions and their revisions.
construction:create, construction:renameMake and rename a Construction.
member:add, member:rename, member:removeChange the members of a Construction’s lists.

Each has its own help: vendor/bin/barntree help template:show.

Options that recur #

OptionMeaning
--jsonMachine-readable output. On success, standard output holds only the JSON. Diagnostics and prompts go to standard error.
--yes, -yConfirms a structural change or a deletion. Scripts, piped input and --no-interaction are refused without it. It never skips validation or the conflict check.
--from-file=PATHReads JSON from a file, or from standard input when the path is -.
--expect-token=TOKENRequires the Template file to be exactly the one you inspected. Required by template:apply. Take it from the File token in template:show.
--expect-revision=REVISIONRequires a Construction to be at the revision you inspected.
--revision=REVISIONReads an earlier snapshot instead of the current one. With --document-id, the Template is named by its document id, and it works after the Template is deleted.
--limit, --pagePages of history: 25 by default, 1 to 100.

Combined changes #

To change several things as one revision, prepare JSON holding name, description, root and types, and apply it. It changes the metadata and the types together, fits the existing tree with the same operation as the app, and keeps the identities of items that survive. A tree in the file is ignored, and tags stay as they were.

barntree template:apply "Allotment" --from-file=changes.json --expect-token=TOKEN --yes
barntree type:edit "Allotment" Shed --from-file=shed.json

A type’s JSON holds the editable fields, name, meaning, kind and of; fields you leave out stay as they are. The JSON result of a write adds operation and changed, and a deletion returns deleted with the document id.

JSON output #

Every JSON result has schemaVersion (1) and barnRoot. A list has documents and errors. A show has the document’s details, savedAt, the view, the complete saved content and the chosen display. A history has the document id, the current revision id, the page, the limit, the number of pages, the total and the revisions, each with its events. Dates are ISO 8601 with a time zone.

$ vendor/bin/barntree template:history Allotment --json | …
{
 "schemaVersion": 1,
 "barnRoot": "…/allotment",
 "documentId": "bd3708f38810ec991ef9a2470b5abe52",
 "currentRevisionId": "06d23b48d178e90552d6283ee018486c",
 "matchesSavedRevision": true,
 "page": 1,
 "limit": 25,
 "pages": 1,
 "total": 4
}

Exit status #

0 on success. 1 for a refusal, a conflict, a declined confirmation, a broken Template or a faulty file. A prompt that is closed or interrupted saves nothing.