@bomb.sh/router is a statically typed entry-point router for command-line applications. An argument parser tells you what the user typed. The router tells you where and how they intend to enter your program, and binds a validated, statically typed model for that entry point.
The process.argv property returns an array containing the command-line
arguments passed when the Node.js process was launched. The first element will
be
execPath
. See process.argv0 if access to the original value
of argv[0] is needed. The second element will be the path to the JavaScript
file being executed. The remaining elements will be any additional command-line
arguments.
For example, assuming the following script for process-args.js:
Returns a copy of a section of an array.
For both start and end, a negative index can be used to indicate an offset from the end of the array.
For example, -2 refers to the second to last element of the array.
@param ― start The beginning index of the specified portion of the array.
If start is undefined, then the slice begins at index 0.
@param ― end The end index of the specified portion of the array. This is exclusive of the element at the index 'end'.
If end is undefined, then the slice extends to the end of the array.
@bomb.sh/router is not a CLI framework. It does not own handlers, effects, output, or process lifetime. It is not a flag parser whose product is a bag of flags either. Its product is a typed intent, and your application decides what that intent does.
Typed intents:parse() returns a discriminated union of every reachable entry point, so a switch on method and route is fully type-checked.
Route-scoped options: Parent and child routes can declare the same option name without ambiguity, because each token binds to the route segment that owns it.
Multiple sources: Bind CLI arguments, environment variables, and JavaScript values onto the same model, with an explicit precedence order.
Standard Schema validation: Zod, ArkType, Valibot, and other Standard Schema libraries work without adapters. Invalid data never reaches your application.
No I/O: The parser is synchronous. It reads only the argv, values, and environment records you pass to it.
Runs everywhere: No runtime-specific APIs, so it runs on Node.js, Deno, and Bun.