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

96.22% Statements 51/53
100% Branches 2/2
50% Functions 1/2
96.22% Lines 51/53

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 47 48 49 50 51 52 53 541x 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 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
  blong grant <capability>       Mint a short-lived capability token
                                 (e.g. blong grant calls --ttl=15m)
 
A target is a positional spelled as a path — it carries a separator: ./server.ts,
dev/, ../suite. A bare word is always an intent, even when a folder of that name
exists: blong dev runs the dev intent, whatever this folder holds.
 
Well-known intents:
  dev            Development features only — introspection, error detail, dev keys
  microservice   Run a realm on its own — its adapters, orchestrators, listeners
  integration    Integration testing — test layers, watch + test reruns (exits when CI is set)
  test-ui        Browser test console — loads the browser test layer without the CI runner
  release        The deployment block — cluster resolution, in-process self-dispatch, no dev refs
  cli            Run a command in-process and exit
  k8s            Write a deployment tree instead of serving and exit
  upgrade        Database creation / seeding and exit
 
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);
}