Welcome to tsargp
Get started with:
Argument parser for TypeScript.
-h, --help A help option. Prints this help message. Uses the next argument
as the name of a nested command. Uses the next argument as the
name of a help format. Uses the remaining arguments as option
filter.
-v, --version A version option. Prints the package version.
-f, --flag A flag option. Can be negated with --no-flag. Deprecated for some
reason.
hello ... A recursive command option. Logs the arguments passed after it.
-b, --boolean <boolean> A boolean option with:
* a paragraph
- inline styles
1. and a list
Values must be one of {'yes', 'no'}. Requires (-se and (-ss ==
['a', 'b'] or -ns != [3, 4])). Defaults to false.
String options:
-s, --stringRegex <my str> A string option. Values must match the regex /^\d+$/. Defaults to
'123456789'. Can be clustered with 's'.
-se, --stringEnum 'one' A string option. Values must be one of {'one', 'two'}. Disallows
inline parameters.
-ss, --strings [<strings>] A strings option. Values are delimited by ','. Values will be
trimmed. Values will be converted to uppercase. Defaults to
['one']. Falls back to ['two'] if specified without parameter.
--stringsLimit 'one'... A strings option. Accepts multiple parameters. Accepts positional
parameters that may be preceded by --. Element count is limited
to 3.
Number options:
-n, --numberRange <my num> A number option. Values must be in the range [-Infinity, 0].
Defaults to -1.23. Can be clustered with 'n'.
-ne, --numberEnum =1 A number option. Values must be one of {1, 2}. Requires inline
parameters.
-ns, --numbers <numbers>... A numbers option. Accepts multiple parameters. Values will be
converted with Math.round. Defaults to [1, 2].
--numbersUnique '1,2' A numbers option. Values are delimited by ','. May be specified
multiple times. Duplicate values will be removed.
Usage:
demo.js [(-h|--help)] [(-v|--version)] # get help
demo.js hello ... # execute the hello command
demo.js [(-f|--flag|--no-flag)] [[(-b|--boolean) <boolean>] (-se|--stringEnum) 'one']
[(-s|--stringRegex) <my str>] [(-n|--numberRange) <my num>] [(-ne|--numberEnum)=1]
[(-ss|--strings) [<strings>]] [(-ns|--numbers) <numbers>...] [[(--stringsLimit|--)]
'one'...] [--numbersUnique '1,2']
MIT License.
Copyright (c) 2024 TrulySimple
Report a bug: https://github.com/trulysimple/tsargp/issues
"Several of them would have protested if they could have found the right arguments."
George Orwell, Animal Farm