parseScriptArgs
parseScriptArgs(
tokens,defs?):object
Parse CLI-style tokens into a ScriptArgs accessor. Supports a flexible set of conventions so callers and scripts do not need to agree on a rigid format:
--name=valueand--name value--flag(boolean true) and--no-flag(boolean false)- short aliases
-x(treated like--x) - repeated flags collapse into a string array
- bare tokens become positional arguments
When declarations are supplied, values are coerced to the declared type, defaults are applied, and required args are validated.
Parameters
tokens
string[]
defs?
ScriptArgDef[] = []
Returns
object
args
args:
ScriptArgs
errors
errors:
string[]