1.0.4 • Published 5 years ago

pargser v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

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)
1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago