Skip to content

Commit

Permalink
let .options() take single options too
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed May 14, 2011
1 parent 3c4cf29 commit d4e21f5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,13 @@ function Argv (args, cwd) {
return a[l].length;
}

self.options = function (opts) {
Object.keys(opts).forEach(function (key) {
self.options = function (key, opt) {
if (typeof key === 'object') {
Object.keys(key).forEach(function (k) {
self.options(k, key[k]);
});
}
else {
var opt = opts[key];

if (opt.alias) self.alias(key, opt.alias);
Expand All @@ -194,7 +199,12 @@ function Argv (args, cwd) {
if (opt.string || opt.type === 'string') {
self.string(key);
}
});

var desc = opt.describe || opt.description || opt.desc;
if (desc) {
self.describe(key, desc);
}
}

return self;
};
Expand Down

0 comments on commit d4e21f5

Please sign in to comment.