Skip to content

Commit

Permalink
Added support for long flags only. Closes #18
Browse files Browse the repository at this point in the history
.option("--whatever", "some stuff")
  • Loading branch information
tj committed Oct 31, 2011
1 parent 81ec7aa commit 8432082
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/commander.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ function Option(flags, description) {
this.required = ~flags.indexOf('<');
this.optional = ~flags.indexOf('[');
this.bool = !~flags.indexOf('-no-');
flags = flags.split(/[ ,|]+/)
this.short = flags.shift();
flags = flags.split(/[ ,|]+/);
if (flags.length > 1) this.short = flags.shift();
this.long = flags.shift();
this.description = description;
}
Expand Down
13 changes: 13 additions & 0 deletions test/test.options.large-only.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Module dependencies.
*/

var program = require('../')
, should = require('should');

program
.version('0.0.1')
.option('--verbose', 'do stuff');

program.parse(['node', 'test', '--verbose']);
program.verbose.should.be.true;

3 comments on commit 8432082

@felixge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3. Thank you so much!

@tj
Copy link
Owner Author

@tj tj commented on 8432082 Oct 31, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np!

@maxwoo-houzz
Copy link

@maxwoo-houzz maxwoo-houzz commented on 8432082 Jul 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add this to the documentation, took a while to find this by searching through "Issues"

edit: actually on second thought, I'll just submit a pull request

Please sign in to comment.