Skip to Content
Nextra 4.0 is released 🎉

Welcome to tsargp

Argument parser for TypeScript. -h, --help A help option. Prints this help message. Uses the next argument as the name of a subcommand. Uses the remaining arguments as option filter. --env A help option. Prints the available environment variables. Uses the remaining arguments as option filter. -v, --version A version option. Prints the package version. -f, --no-flag A flag option. Deprecated for some reason. hello ... A subcommand. Logs the arguments passed after it. -b, --boolean <param> A boolean option with: * a paragraph; - a style; and 1. a list Values must be one of {'yes', 'no'}. Requires (-sc or (-sa == ['a', 'b'] and -na != [1, 2])). Defaults to false. String options: -sr, --strRegex my str A string option. Can be clustered with s. Values must match the regex /^\d+$/. Defaults to '123456789'. -sc, --strChoice 'one' A string option. Disallows inline parameters. Values must be one of {'one', 'two'}. -sa, --strArray [<str>...] A string array option. Can be clustered with S. Accepts multiple parameters. Values can be delimited with ','. If not supplied, will be read from the standard input. Defaults to ['one']. --strArrayLimit ['one'...] A string array option. Accepts multiple parameters. Accepts positional arguments. Element count is limited to 3. Number options: -nr, --numRange my num A number option. The minimum accepted value is -2. Can be clustered with n. Defaults to -1.23. -nc, --numChoice =1 A number option. Requires inline parameters. Values must be one of {'1', '2'}. -na, --numArray [<num>...] A number array option. Can be clustered with N. Accepts multiple parameters. Defaults to [1, 2]. --numArrayUnique ['1,2'...] A number array option. Accepts multiple parameters. Values can be delimited with ','. Can be supplied multiple times. Duplicate values will be removed. Usage: tsargp [-h|--help] [--env] [-v|--version] # get help tsargp hello ... # execute the hello command tsargp [-f|--no-flag] [(-sc|--strChoice) 'one' [(-b|--boolean) <param>]] [(-sr|--strRegex|-s) my str] [(-nr|--numRange|-n) my num] [(-nc|--numChoice)=1] [(-sa|--strArray|-S) [<str>...]|-] [(-na|--numArray|-N) [<num>...]] [--strArrayLimit] ['one'...] [--numArrayUnique ['1,2'...]] [-- [...]] Report bugs: https://github.com/dsogari/tsargp/issues

“Several of them would have protested if they could have found the right arguments.”

— George Orwell, Animal Farm

Last updated on