2.2.8 • Published 7 years ago
argvark v2.2.8
argvark
Intuitive command-line argument parsing for Node.js modules.
Install
npm install argvarkUsage
> node some-module -p --age=123 --name="John Doe"
var argv = require('argvark');
// Simple matches:
p = argv('-p'); // '-p'
// Verbose Parameters:
age = argv(/--age=(\d+)/) // 123
name = argv(/--name="(.+?)"/) // 'John Doe'Use after() when the value is separated from the param by a space:
> node some-module port 8888
argv.after('port') // 8888Use flag() when you want a Boolean value indicating the flag presence, or when
you don't want to build your own pattern just to check flags. This uses !!argv(/-\w+[FLAG]/)
so it supports both standard flag formats:
> node some-module -abCD
> node some-module -a -b -C -D
argv.flag('b') // true
argv.flag('D') // true
argv.flag('X') // falseUnmatched patterns evaluate to undefined
location = argv('--location') // undefinedMaking changes
Just run npm test to make sure everything is still working. Add tests for
fixes etc.