Command line

Pages

The legato set, get, list, delete and schema commands, with what each one prints.

Commands

CommandResult
legato set <page-id> [file]Checks a page, then replaces the whole of it with the JSON object in a file, or on stdin when there is no file.
legato get <page-id>Prints the page with its version and status.
legato listLists the pages.
legato delete <page-id>Moves the page to the Trash.
legato schema [part]Prints the page format, or one part of it: page, sources, rules, actions, period, params, notify, title_from or a card type.
legato preview [file]Fills a page's cards from a sample answer, offline, as preview_page does. It reads {"page_id" or "page", "source", "sample"} from the file or stdin.

--if-match <version> works with set and delete. The command acts only if the page is still at that version, and is refused with version_mismatch if it has changed. With set, --if-match none writes the page only if no page has that id yet.

The input to set must be a JSON object. A refusal prints {"error": {...}} on stdout and exits with status 1. See Writing and versions.

Examples and success output

bash
printf '%s\n' '{"title":"Example","cards":[{"id":"note","type":"text","body":"Hello"}]}' | legato set example --if-match none
legato get example
legato list
legato schema stat
legato delete example

The first command adds a page called Example to your sidebar, and the last one moves it to the Trash. Each command prints a JSON object with these fields:

CommandSuccess output
setid, version, changed, created, loaded, collection and placement. loaded is what Legato said when it loaded the page, or null if it hasn't loaded it yet. A note explains a null, or a page that is saved but not shown.
getid, version, modified, page, name, status, collection and placement. If the file isn't a JSON object, text holds its contents, and page, name, collection and placement are left out.
listfolder and pages. Each page has id, version, modified, title, name, collection and placement. Once Legato has read the page it also has ok, with error when the page couldn't be loaded.
schema statpart, which is stat, and its schema. Without a part, the answer has parts, cards and note.
deleteid, deleted and note.

collection and placement say where the page sits in the sidebar. placement is one of:

  • recorded: the page is in collection.
  • pending: Legato hasn't loaded the page yet. collection is where it will go, and placement_note says so.
  • ungrouped: there are no collections.
  • detail: the page has "sidebar": false, so it isn't in the sidebar.

The delete in the example prints:

json
{
  "deleted" : true,
  "id" : "example",
  "note" : "Moved to the Trash; put it back from there to restore it."
}