Comparing version 0.0.1 to 0.0.2
@@ -47,3 +47,8 @@ /** | ||
var curName = _cleanUpOptionName(current); | ||
rtn.opts[curName] = true; | ||
var curNameSplit = curName.split('='); | ||
if (curNameSplit[1]) { | ||
rtn.opts[curNameSplit[0]] = curNameSplit[1]; | ||
} else { | ||
rtn.opts[curNameSplit[0]] = true; | ||
} | ||
} else { | ||
@@ -50,0 +55,0 @@ // or set a value to it |
{ | ||
"name": "clarg", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Simple command line argument parser", | ||
@@ -5,0 +5,0 @@ "main": ".", |
@@ -13,18 +13,33 @@ # clarg | ||
No questions asked, no prescribed way of doing things. Just a simple object. | ||
## Usage | ||
Simply import clarg anywhere in your code and it will output an object. | ||
You don't have to specify any options upfront, just require this module | ||
and execute it. | ||
It doesn't matter where in code you run it - you will always get the same result | ||
which is really just a broken down list of arguments and options passed to the process. | ||
It supports options specified with single dashes, double dashes and their values | ||
after a space or an equal sign. Anything goes as long as your options come after arguments. | ||
``` | ||
var clarg = require('clarg'); | ||
var arguments = require('clarg')(); | ||
console.log(arguments); | ||
``` | ||
var arguments = clarg(); | ||
Running this script with | ||
`node test.js start countdown --format=long -detach -parse=yes` | ||
will produce something like this: | ||
// node index.js start --debug --format long | ||
// => {args: ['start'], opts: [{debug: true, format: 'long'}]} | ||
``` | ||
{ | ||
args: [ 'start', 'countdown' ], | ||
opts: [ format: 'long', detach: true, parse: 'yes' ], | ||
raw: [ 'start', 'countdown', '--format=long', '-detach', '-parse=yes' ] | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3163
4
58
45