diff --git a/CLAUDE.md b/CLAUDE.md index 9bf54dc..dd71324 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,7 +6,7 @@ Transcript-based shell integration test runner. Bun + TypeScript. - `bun test` — run unit tests - `bunx tsc --noEmit` — type check -- `bun run src/cli/index.ts [files...]` — run shout CLI +- `bun run src/cli/index.ts test [files...]` — run shout CLI ## Architecture diff --git a/README.md b/README.md index 124cdfc..93dc3d3 100644 --- a/README.md +++ b/README.md @@ -33,21 +33,21 @@ ls: missing: No such file or directory ## Usage ``` -$ shout +$ shout test ............... 15 passed in 23ms ``` -`shout` runs code in a temp directory. `-k`/`--keep` keeps it around. +`shout test` runs code in a temp directory. `-k`/`--keep` keeps it around. `--update` will modify `.shout` files to match reality, without running any tests. Each line in a `.shout` file is run sequentially, unless `--parallel` is passed. ``` -Usage: shout [options] [files...] +Usage: shout test [options] [files...] -shell output tester. +Run .shout test files Arguments: files Files or directories to test @@ -61,5 +61,10 @@ Options: -v, --verbose Print each command as it runs --parallel Run files in parallel -h, --help display help for command +``` + +Print an example `.shout` file: ``` +$ shout example +``` diff --git a/index.html b/index.html index e6f0b24..854a6a9 100644 --- a/index.html +++ b/index.html @@ -200,7 +200,7 @@

Run it

-
$ shout
+  
$ shout test
 ...............
 15 passed in 23ms

Each file gets a fresh temp directory and its own /bin/sh session. State carries between commands within a file.

@@ -208,16 +208,16 @@

Update expectations

-
$ shout --update
+
$ shout test --update

Rewrites your .shout files with the actual output. No more copy-pasting from the terminal.

Usage

-
$ shout --help
-Usage: shout [options] [files...]
+  
$ shout test --help
+Usage: shout test [options] [files...]
 
-shell output tester.
+Run .shout test files
 
 Arguments:
   files            Files or directories to test
diff --git a/src/cli/index.ts b/src/cli/index.ts
index 735b737..82f45b5 100755
--- a/src/cli/index.ts
+++ b/src/cli/index.ts
@@ -46,6 +46,10 @@ async function findShoutFiles(paths: string[]): Promise {
 program
   .name("shout")
   .description("$ shell output tester")
+
+program
+  .command("test")
+  .description("Run .shout test files")
   .argument("[files...]", "Files or directories to test")
   .option("-u, --update", "Rewrite expected output in-place with actual output")
   .option("-k, --keep", "Keep temp directories after run")
@@ -54,28 +58,7 @@ program
   .option("--timeout ", "Per-command timeout", "10s")
   .option("-v, --verbose", "Print each command as it runs")
   .option("--parallel", "Run files in parallel")
-  .option("--example", "Print an example .shout file and exit")
   .action(async (fileArgs: string[], opts) => {
-    if (opts.example) {
-      console.log(`# Example .shout file
-$ echo hello
-hello
-
-$ echo "one"; echo "two"; echo "three"
-one
-...
-three
-
-$ cat nonexistent
-cat: nonexistent: ...
-[1]
-
-$ true
-[0]`)
-      process.exit(0)
-    }
-
-
     const timeoutMs = parseDuration(opts.timeout)
     const paths = fileArgs.length > 0 ? fileArgs : ["."]
     const files = await findShoutFiles(paths)
@@ -171,4 +154,25 @@ $ true
     process.exit(failures.length > 0 ? 1 : 0)
   })
 
+program
+  .command("example")
+  .description("Print an example .shout file")
+  .action(() => {
+    console.log(`# Example .shout file
+$ echo hello
+hello
+
+$ echo "one"; echo "two"; echo "three"
+one
+...
+three
+
+$ cat nonexistent
+cat: nonexistent: ...
+[1]
+
+$ true
+[0]`)
+  })
+
 program.parse()