NAME
getopt-long
- Extended processing of command line options with automatic help
SYNOPSIS
const getOpts = ; const cliOpts = shortHandFlag: 'f' shortHandProperty: 'short-hand-property|p=s' someFile: long: 'some-file' short: 's' type: 'string' description: 'Name of some file' parameter: 'FILE' count: long: 'count' type: 'number' someOptionalSetting: short: 'o' description: 'Enable some optional setting' someAdditionalSetting: short: 'O' description: 'Enable some additional setting, and also some optional setting' implies: someOptionalSetting: true extraProperties: long: 'extra-properties' type: 'string' multi: true description: 'Pass additional options, can be passed multiple times' requiredProperty: long: 'required-property' type: 'string' description: 'This option is required, and will throw an error if missing' required: 'This field will be the error message' help: usage: 'script [OPTS...] ARGUMENTS...' { console; console; } ; let opts;try opts = ;catch err console; process; consolediropts;
$ script firstArg -fs fileName -p prop --count 42 secondArg --extra-properties two -O --extra-properties one --required-property token thirdArgg
$ script --helpUsage: script [OPTS...] ARGUMENTS... -f shortHandFlag-p, --short-hand STRING shortHandProperty-s, --some-file FILE Name of some file--count NUMBER count-o Enable some optional setting-O Enable some additional setting, and also some optional setting--extra-properties STRING Pass additional options, can be passed multiple times--required-property STRING REQUIRED: This option is required, and will throw an error