-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'value-equals-default-value'
- Loading branch information
Showing
22 changed files
with
410 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
tmp | ||
.coveralls.yml | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,14 @@ | ||
'use strict' | ||
|
||
/** | ||
* A module for testing for and extracting names from options (e.g. `--one`, `-o`) | ||
* | ||
* @module option | ||
* @private | ||
*/ | ||
|
||
class Arg { | ||
constructor (re) { | ||
this.re = re | ||
} | ||
|
||
class ArgRegExp extends RegExp { | ||
name (arg) { | ||
return arg.match(this.re)[1] | ||
return arg.match(this)[1] | ||
} | ||
test (arg) { | ||
return this.re.test(arg) | ||
} | ||
} | ||
|
||
const option = { | ||
short: new Arg(/^-([^\d-])$/), | ||
long: new Arg(/^--(\S+)/), | ||
combined: new Arg(/^-([^\d-]{2,})$/), | ||
isOption (arg) { return this.short.test(arg) || this.long.test(arg) }, | ||
optEquals: new Arg(/^(--\S+?)=(.*)/), | ||
VALUE_MARKER: '552f3a31-14cd-4ced-bd67-656a659e9efb' // must be unique | ||
} | ||
|
||
module.exports = option | ||
exports.short = new ArgRegExp('^-([^\\d-])$') | ||
exports.long = new ArgRegExp('^--(\\S+)') | ||
exports.combined = new ArgRegExp('^-([^\\d-]{2,})$') | ||
exports.isOption = arg => exports.short.test(arg) || exports.long.test(arg) | ||
exports.optEquals = new ArgRegExp('^(--\\S+?)=(.*)') | ||
exports.VALUE_MARKER = '552f3a31-14cd-4ced-bd67-656a659e9efb' // must be unique |
Oops, something went wrong.