All files / core/blong-gogo/src cliHelp.ts

95.65% Statements 44/46
100% Branches 2/2
50% Functions 1/2
95.65% Lines 44/46

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 471x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 1x 1x 1x 1x 1x 1x 1x      
/**
 * Shared `--help` handling for the `blong` / `blong-watch` CLIs.
 *
 * Both binaries hand-roll their argument parsing with `minimist`, which treats
 * `--help`/`-h` as unused named flags. Without this short-circuit the CLI falls
 * through to `autoRun`, finds no suite entry point in the working directory and
 * throws — which looks like a crash. The check must run before the realm-create
 * and `autoRun` logic so help works from any directory.
 */
 
export const USAGE = `blong — run a Blong suite / realm (intents are positional arguments)
 
Usage:
  blong                          Run the suite in the current folder
                                 (default intents: microservice + integration + dev)
  blong <file> [intents...]      Run a specific suite file (e.g. ./server.ts)
  blong <intent>...              Run with only the given intents (e.g. integration)
  blong realm <name> [--object]  Scaffold a new realm
  blong create realm <name>      Scaffold a new realm
 
Well-known intents:
  dev            Development — verbose logs, hot reload
  integration    Integration testing — watch + test reruns (exits when CI is set)
  microservice   Run a realm as a standalone microservice
  prod           Production / UAT
  cli            Run a command in-process and exit — no HTTP server, no watcher
  db             Database creation / seeding (short-lived)
  debug          Enable /api/sys/* introspection + stack traces
 
Options:
  --help, -h     Show this help and exit
`;
 
/** True when the parsed argv contains `--help` or `-h`. */
export function shouldShowHelp(argv: Record<string, unknown>): boolean {
    return argv.help === true || argv.h === true;
}
 
/**
 * Write the usage text to stdout. `onFlushed` runs after the write has been
 * flushed so piping the output to another process cannot be truncated by an
 * immediate `process.exit()`.
 */
export function printUsage(onFlushed?: () => void): void {
    process.stdout.write(USAGE, onFlushed);
}