1.0.4 • Published 5 years ago
pargser v1.0.4
pargser
This is a friendly command-line argument parser.
Test
$ npm test
Usage
const Argvments = require('pargser');
const args = new Argvments(process.argv);
console.log(args.argArray) // process.argv without the first two entries
console.log(args.argString) // joined arg array
console.log(args.file) // script/program name
console.log(args.__args) // object with parsed arguments
console.log(args.get("argumentKey", "fallback if key doesn't exist (null is default)")); // get value of argument ("beginning '--' and '-' are stripped, so you can't have all three keys "argument-key", "-argument-key", and "--argument-key")
- Booleans ("true"/"false") in the arguments are parsed to their respective values.
- "null" and "nil" are parsed to null.
- Numbers (can deal with commas and decimals in numbers) are parsed to their respective value.
- Prepending "-no" to the beginning of a switch sets it to false rather than true in __args.
- Key names are converted to camel-case.
- Flags can be used with equals signs (
... --this-flag=false
) or without (... --this-flag false
)