diff --git a/CHANGELOG.md b/CHANGELOG.md index 99fa61e1..89df7325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to Lobster will be documented in this file. ## Unreleased +- Show the usage for `lobster help run`, `help resume`, `help doctor`, `help version` and `help help`, the same text `lobster run --help` prints, instead of failing with `Unknown command: run` (exit code 2); thanks @KrasimirKralev. - Reject a non-object or empty `--args-json` on `lobster run`, `lobster graph`, and `workflows.run` instead of running the workflow on its default args or failing with a raw `TypeError`; thanks @KrasimirKralev. ## 2026.11.1 - 2026-11-05 diff --git a/src/cli.ts b/src/cli.ts index 7a781720..c7e4e05b 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -10,6 +10,8 @@ import type { WorkflowGraphFormat } from "./workflows/graph.js"; import { finalizePipelineToolRun } from "./pipeline_resume_state.js"; import { forceTerminateAbortableProcesses } from "./abortable_process.js"; +const USAGE_TOPICS = new Set(["run", "resume", "doctor", "version", "help"]); + export async function runCli(argv) { const cancellation = createCliCancellation(); try { @@ -49,6 +51,11 @@ async function runCliWithSignal( process.stdout.write(graphHelpText()); return; } + // These built-ins are documented in the top-level usage, which ` --help` prints too. + if (USAGE_TOPICS.has(topic)) { + process.stdout.write(helpText()); + return; + } const cmd = registry.get(topic); if (!cmd) { process.stderr.write(`Unknown command: ${topic}\n`); diff --git a/test/cli_run_errors.test.ts b/test/cli_run_errors.test.ts index 33fa079a..d3c85313 100644 --- a/test/cli_run_errors.test.ts +++ b/test/cli_run_errors.test.ts @@ -139,3 +139,26 @@ test("help graph shows the graph help listed under Commands", () => { assert.match(result.stdout, /--format\s+Output format: mermaid \(default\), dot, ascii/); assert.equal(result.stderr, ""); }); + +for (const topic of ["run", "resume", "doctor", "version", "help"]) { + test(`help ${topic} shows the usage that documents it instead of Unknown command`, () => { + const result = spawnSync(process.execPath, ["bin/lobster.js", "help", topic], { + encoding: "utf8", + }); + const flagHelp = spawnSync(process.execPath, ["bin/lobster.js", topic, "--help"], { + encoding: "utf8", + }); + assert.equal(result.status, 0); + assert.equal(result.stderr, ""); + assert.match(result.stdout, new RegExp(`^ lobster ${topic}\\b`, "m")); + assert.equal(result.stdout, flagHelp.stdout); + }); +} + +test("help with an unknown topic still fails", () => { + const result = spawnSync(process.execPath, ["bin/lobster.js", "help", "nope"], { + encoding: "utf8", + }); + assert.equal(result.status, 2); + assert.equal(result.stderr, "Unknown command: nope\n"); +});