cli-argparse
Advanced tools
Comparing version
@@ -137,4 +137,2 @@ var short = '-', long = '--'; | ||
if(stop instanceof RegExp) { | ||
//arg = arg.replace(stop, ''); | ||
//if(arg === '') arg = undefined; | ||
stop = arg.replace(stop, ''); | ||
@@ -147,2 +145,5 @@ out.skip = stop ? [stop] : []; | ||
out.unparsed = out.unparsed.concat(out.skip); | ||
if(arg === out.raw[0]) { | ||
out.empty = true; | ||
} | ||
break; | ||
@@ -149,0 +150,0 @@ }else if(opt || ~equals || lre.test(arg)) { |
{ | ||
"name": "cli-argparse", | ||
"version": "0.3.12", | ||
"version": "0.3.13", | ||
"description": "Lightweight argument parser", | ||
@@ -5,0 +5,0 @@ "author": "muji <noop@xpm.io>", |
@@ -101,2 +101,13 @@ # Parse | ||
#### Options | ||
* `alias`: Map of argument names to property names. | ||
* `flags`: Array of argument names to be treated as flags. | ||
* `options`: Array of argument names to be treated as options. | ||
* `strict`: A boolean that indicates only arguments specified as `options` or `flags` should be parsed. | ||
* `flat`: A boolean that creates a flat result structure. | ||
* `stop`: Array of strings or patterns to stop parsing on, the special pattern `--` is always respected first. | ||
Note that you should **not** use the negated long form (--no-highlight) when specifying these hints, always use the positive form. | ||
#### Result | ||
@@ -111,15 +122,10 @@ | ||
* `unparsed`: Array of values that were not parsed. | ||
* `skip`: Array of args skipped upon `--` or a custom stop pattern. | ||
* `stop`: If a stop pattern matched this will contain the pattern that matched (string or regexp). | ||
* `empty`: Set to `true` if a stop pattern matched on the first argument. | ||
#### Options | ||
##### Aliases | ||
* `alias`: Map of argument names to property names. | ||
* `flags`: Array of argument names to be treated as flags. | ||
* `options`: Array of argument names to be treated as options. | ||
* `strict`: A boolean that indicates only arguments specified as `options` or `flags` should be parsed. | ||
* `flat`: A boolean that creates a flat result structure. | ||
Aliases allow arguments to map to meaningful property names that will be set on the result object `options` and `flags`. | ||
Note that you should **not** use the negated long form (--no-highlight) when specifying these hints, always use the positive form. | ||
##### Aliases | ||
Aliases are mapped on the raw argument name, to map `-v | --verbose` to a `verbose` property use `{'-v --verbose': 'verbose'}`. | ||
@@ -126,0 +132,0 @@ |
@@ -89,2 +89,10 @@ var expect = require('chai').expect; | ||
}); | ||
it('should set noop on stop at arg zero', function(done) { | ||
var args = ['--', 'server', '--port=80', '--host=localhost']; | ||
var result = parse(args, {stop: [false]}); | ||
expect(result.stop).to.eql('--'); | ||
expect(result.empty).to.eql(true); | ||
done(); | ||
}); | ||
}) |
36519
2.03%833
0.97%152
4.11%