diff --git a/CLI.md b/CLI.md new file mode 100644 index 0000000..1f85b37 --- /dev/null +++ b/CLI.md @@ -0,0 +1,124 @@ +# RuDS Command Line, Headless Server, and Terminal UI + +## In this article + +- [What the CLI is](#what-the-cli-is) +- [Installing the CLI](#installing-the-cli) +- [Global flags and output](#global-flags-and-output) +- [Command reference](#command-reference) +- [Creating content from the command line](#creating-content-from-the-command-line) +- [Running the headless server](#running-the-headless-server) +- [Using the terminal UI](#using-the-terminal-ui) +- [How the CLI and the desktop app stay in sync](#how-the-cli-and-the-desktop-app-stay-in-sync) + +## What the CLI is + +`bds-cli` is the automation surface of RuDS. It runs the same engines against the same application database and the same projects as the desktop app — there is no separate state, no export/import step, and no second configuration. Anything the CLI changes shows up in an open desktop window automatically. + +Typical uses: scripted rebuilds and site generation, publishing from CI or cron, creating posts from other tools, importing images in bulk, running utility Lua scripts, and starting the headless server or the terminal UI. + +## Installing the CLI + +Install the launcher from the desktop app under **Settings → Data**, or run `bds-cli install` from a packaged binary. Both place a small forwarding launcher in `~/.local/bin` that executes the packaged CLI next to the shared runtime. Make sure `~/.local/bin` is on your `PATH`. + +## Global flags and output + +| Flag | Effect | +|---|---| +| `--json` | Print a stable JSON result envelope instead of human-readable text | +| `--airplane` | Block network commands and route automatic AI work to the local (airplane) endpoint | + +The JSON envelope always has the shape `{"ok": bool, "command": string, "message": string, "data": object, "progress": [string], "notices": [string]}`, which makes the CLI safe to drive from scripts and LLM agents. Errors exit with code 1 and a formatted message on stderr; unknown commands and invalid options do the same. + +With `--airplane`, `upload`, `push`, and `pull` are refused, and AI-assisted steps (language detection, translation, image enrichment) use the configured airplane endpoint. When no local endpoint is configured, the CLI prints a notice and falls back to offline heuristics where they exist — the command-line equivalent of the desktop's airplane-mode toast. + +## Command reference + +All commands operate on the active project from the shared project registry unless stated otherwise. + +| Command | What it does | +|---|---| +| `rebuild` | Rebuild the cache database from the active project's files. `--incremental` applies only detected differences and imports orphan files | +| `repair ` | Run one derived-data repair: `post-links`, `media-links`, `thumbnails`, `embeddings`, or `search` | +| `render` | Render the generated site. `--incremental` validates output and applies only differences; `--force` re-renders everything, ignoring content hashes | +| `upload` | Upload generated HTML, thumbnails, and media using the project publishing settings, waiting for the publish job | +| `push` | Push the project repository to origin | +| `pull` | Fast-forward pull, then reconcile the cache database with the pulled files | +| `post` | Create a post from flags or JSON on stdin (see below) | +| `media ` | Import one image with best-effort AI enrichment and translations. `--language` overrides detection | +| `gallery ` | Create a post and import/link all supplied images through the shared gallery pipeline | +| `config get\|set\|list` | Read or update global application settings; `list` shows effective values with secrets redacted | +| `project list\|add\|switch` | List, add (`--name` optional), or switch projects in the shared registry | +| `lua