From 2e6777e06e3f3e9d59ec847b98e0cb676d04296a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 01:15:28 -0300 Subject: main: the command line is commands that describe themselves, over the tree that does The user: "the cli should be like a living documentation, similar to 9p and maybe even share the source code but with different sinks", rex's CLI the model. pardes [flags] [FILE] opens, starts or pages as it did; a first word naming a command is that command (a file named so is ./ps, or after --): ps, attach [NAME], kill NAME|--all, new [flags] [FILE] for sessions; do WORD [ARG] and words [GROUP] for the builtins; fs VERB [PATH] for the tree; help [CMD|WORD|PATH], completion SHELL, skill, version. One definition, several sinks. main.zig's `cmds` (an EnumArray over the Cmd enum: group, args, first-screen line, doc, examples, see-also) is both what args[1] is matched against and every command's help; `flags` (over the Flag enum: what it takes, its doc, session/open/old) is both the flag loop's parser and `help new`. The 70-line help_text and the flag enum kept apart from it are gone; every flag behaves as before, and --ps, --attach[=NAME], --kill=NAME, --kill-all, -h/--help and --version are the commands' old spellings for a release (EDITOR='pardes --wait' unchanged). What a word or a file does is the tree's to say: words, help WORD, help PATH, fs and the completions read /commands and /README over cloud9's Fsys, from the session (-s NAME, else $PARDES_9P, else the only one whose socket answers) or, with none, from a core this process makes (Pardes.create, never stepped: no shell, file or socket) and serves on one end of a socket pair to an Fsys on the other (`Here`: cloud9's engine, one thread), so both are the same client over the same tree. With no session, fs ls/stat/help/complete and a read of README, commands or ctl answer; a read of anything else, or a write, says it is a running session's and how to start one. do picks the ctl by /commands' scope (a pane's word needs $PARDES_PANE or -p N) and prints a refusal in the session's words. completion prints a bash, fish or zsh script that asks `pardes completion -- WORDS` back. skill prints src/skill.txt, the recipes and traps, which leaves the inventory to pardes help. version adds the 9P the tree speaks. The reference's "The pardes command" includes docs/typ/command-line.txt, `pardes help --all` (never a session's), which the builtins-json step (-Dplatform=tui) now writes too; a main.zig test fails when it is stale. test/process/cli.zig: five cases through the binary, with and without a session; flags' eight pass unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- build.zig | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 7bd43795..71c8637b 100644 --- a/build.zig +++ b/build.zig @@ -878,7 +878,7 @@ pub fn build(b: *std.Build) void { // `typst compile` reads it too; a unit test fails when it is stale. // A terminal build writes builtins-tui.json and a window build // builtins-gui.json; style.typ merges the two into one glossary. - const builtins_json_step = b.step("builtins-json", "rewrite docs/typ/builtins-.json from the builtin registry (-Dplatform=tui or gui)"); + const builtins_json_step = b.step("builtins-json", "rewrite docs/typ/builtins-.json from the builtin registry, and with tui docs/typ/command-line.txt from pardes help --all (-Dplatform=tui or gui)"); if (requested_platform == .tui or requested_platform == .gui) { const gen = b.addExecutable(.{ .name = "pardes-gen-builtins-json", .root_module = b.createModule(.{ .target = target, @@ -1184,6 +1184,19 @@ pub fn build(b: *std.Build) void { .root_module = root_mod, }); installHome(b, exe, home_bin); + // docs/typ/command-line.txt: `pardes help --all`, the commands' + // help and the tree's README as this build prints them (never a + // session's), which the reference's "The pardes command" shows; + // main.zig's test fails when it is stale. The terminal's build + // writes it, the window's prints the same. + if (requested_platform == .tui) { + const run_help = b.addRunArtifact(exe); + run_help.addArgs(&.{ "help", "--all" }); + const update = b.addUpdateSourceFiles(); + update.addCopyFileToSource(run_help.captureStdOut(.{}), "docs/typ/command-line.txt"); + builtins_json_step.dependOn(&update.step); + for (doc_renders) |r| if (r) |run| run.step.dependOn(&update.step); + } // The addons, a step each: the default install is the binaries // alone, and `zig build image pdf` (or `addons`) puts the libraries // where the start scan finds them, /lib/pardes/addons (and -- cgit v1.3