Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename function for make opts/args array-value: push() -> arr().

  • Loading branch information...
commit abf91401b884d45e7c42fe611739d659f78ed263 1 parent 966742b
@veged authored
View
4 README.md
@@ -150,7 +150,7 @@ Set a type of option. Mainly using with Boolean for options without value.<br>
**@param** *Object* `_type`<br>
**@returns** *COA.Opt* `this` instance (for chainability)
-#### Opt.push
+#### Opt.arr
Makes an option accepts multiple values.<br>
Otherwise, the value will be used by the latter passed.<br>
**@returns** *COA.Opt* `this` instance (for chainability)
@@ -208,7 +208,7 @@ Set a long description for argument to be used anywhere in text messages.<br>
**@param** *String* `_title` argument title<br>
**@returns** *COA.Arg* `this` instance (for chainability)
-#### Arg.push
+#### Arg.arr
Makes an argument accepts multiple values.<br>
Otherwise, the value will be used by the latter passed.<br>
**@returns** *COA.Arg* `this` instance (for chainability)
View
2  lib/arg.js
@@ -33,7 +33,7 @@ exports.Arg = Arg = (function() {
Otherwise, the value will be used by the latter passed.
@returns {COA.Arg} this instance (for chainability)
*/
- Arg.prototype.push = Opt.prototype.push;
+ Arg.prototype.arr = Opt.prototype.arr;
/**
Makes an argument required.
@returns {COA.Arg} this instance (for chainability)
View
4 lib/cmd.js
@@ -179,7 +179,7 @@ exports.Cmd = Cmd = (function() {
Cmd.prototype._ejectOpt = function(opts, opt) {
var pos;
if ((pos = opts.indexOf(opt)) >= 0) {
- if (opts[pos]._push) {
+ if (opts[pos]._arr) {
return opts[pos];
} else {
return opts.splice(pos, 1)[0];
@@ -218,7 +218,7 @@ exports.Cmd = Cmd = (function() {
}
} else {
if (arg = (nonParsedArgs || (nonParsedArgs = this._args.concat())).shift()) {
- if (arg._push) {
+ if (arg._arr) {
nonParsedArgs.unshift(arg);
}
arg._parse(i, args);
View
6 lib/opt.js
@@ -64,8 +64,8 @@ exports.Opt = Opt = (function() {
Otherwise, the value will be used by the latter passed.
@returns {COA.Opt} this instance (for chainability)
*/
- Opt.prototype.push = function() {
- this._push = true;
+ Opt.prototype.arr = function() {
+ this._arr = true;
return this;
};
/**
@@ -144,7 +144,7 @@ exports.Opt = Opt = (function() {
if (this._validate) {
val = this._validate(val);
}
- if (this._push) {
+ if (this._arr) {
(opts[_name = this._name] || (opts[_name] = [])).push(val);
} else {
opts[this._name] = val;
View
2  src/arg.coffee
@@ -35,7 +35,7 @@ exports.Arg = class Arg
Otherwise, the value will be used by the latter passed.
@returns {COA.Arg} this instance (for chainability)
###
- push: Opt::push
+ arr: Opt::arr
###*
Makes an argument required.
View
4 src/cmd.coffee
@@ -174,7 +174,7 @@ exports.Cmd = class Cmd
_ejectOpt: (opts, opt) ->
if (pos = opts.indexOf(opt)) >= 0
- if opts[pos]._push
+ if opts[pos]._arr
opts[pos]
else
opts.splice(pos, 1)[0]
@@ -216,7 +216,7 @@ exports.Cmd = class Cmd
# arg
else
if arg = (nonParsedArgs or= @_args.concat()).shift()
- if arg._push then nonParsedArgs.unshift arg
+ if arg._arr then nonParsedArgs.unshift arg
arg._parse i, args
else
@errorExit 'Unknown argument', i
View
6 src/opt.coffee
@@ -58,8 +58,8 @@ exports.Opt = class Opt
Otherwise, the value will be used by the latter passed.
@returns {COA.Opt} this instance (for chainability)
###
- push: ->
- @_push = true
+ arr: ->
+ @_arr = true
@
###*
@@ -124,7 +124,7 @@ exports.Opt = class Opt
_saveVal: (opts, val) ->
if @_validate then val = @_validate val
- if @_push
+ if @_arr
(opts[@_name] or= []).push val
else
opts[@_name] = val
View
13 tests/a.js
@@ -0,0 +1,13 @@
+require('../lib/coa').Cmd()
+ .name('arr')
+ .title('Array value test')
+ .helpful()
+ .opt()
+ .name('arr').title('Array')
+ .short('a').long('arr')
+ .arr()
+ .act(function(opts) {
+ console.log(opts.arr);
+ })
+ .end()
+ .parse(['-a', '1', '-a', '2']);
Please sign in to comment.
Something went wrong with that request. Please try again.