2.2.8 • Published 7 years ago

argvark v2.2.8

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

argvark

Intuitive command-line argument parsing for Node.js modules.

Install

npm install argvark

Usage

> 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') // 8888

Use 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') // false

Unmatched patterns evaluate to undefined

location = argv('--location')    // undefined

Making changes

Just run npm test to make sure everything is still working. Add tests for fixes etc.

2.2.8

7 years ago

2.2.7

7 years ago

2.2.3

10 years ago

2.2.2

10 years ago

2.2.1

10 years ago

2.2.0

10 years ago

2.1.2

10 years ago

2.1.1

10 years ago

2.1.0

10 years ago

2.0.0

10 years ago

1.0.0

10 years ago