parseArgs
functionThe command-line surface, re-exported so the package's declared types entry point resolves to
something.
package.json advertises exports["."].types, but this module exported nothing, so the
published .d.ts was empty and the generated API reference was a title with no body. These are
the same symbols the binary itself parses its arguments with, and the same ones the test suite
already covers, publishing them costs nothing and lets a caller embedding the hub reuse the
argument contract instead of re-deriving it.
signature
parseArgs(argv, env): CliArgsReads --port, --history-size and --token from an argument list.
Parameters
| Name | Type | Description |
|---|---|---|
argv | readonly string[] | Arguments after the executable and script (i.e. process.argv.slice(2)). |
| Name | Type | Description |
|---|---|---|
env | Readonly<Record<string, string | undefined>> | Environment to read TOKEN_ENV from when --token is absent (pass
process.env). An empty value counts as unset. Defaults to an empty environment. |
Returns
CliArgs, The validated options.
Example
example
parseArgs(["--port", "9900"]); // { port: 9900, historySize: 1000 }
parseArgs([], { YOLTRA_DEVTOOLS_TOKEN: "s3cret" }); // { port: 9800, historySize: 1000, token: "s3cret" }