Skip to content

Commit

Permalink
add support for harthur#66; in *theory* it was already partly there i…
Browse files Browse the repository at this point in the history
…n the 'full' option regex, but the `--no-option` vs. `--option` doesn't seem to be checked thoroughly yet.
  • Loading branch information
GerHobbelt committed Jun 9, 2015
1 parent f73f0fe commit 11fbe68
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nomnom.js
Expand Up @@ -482,9 +482,9 @@ ArgParser.prototype.setOption = function(options, arg, value) {


/* an arg is an item that's actually parsed from the command line
e.g. "-l", "log.txt", or "--logfile=log.txt" */
e.g. "-l", "-l+", "log.txt", or "--logfile=log.txt" */
var Arg = function (str) {
var abbrRegex = /^\-(\w+?)$/,
var abbrRegex = /^\-(\w+?)([+-]?)$/,
fullRegex = /^\-\-(no\-)?(.+?)(?:=(.+))?$/,
valRegex = /^[^\-].*/;

Expand All @@ -502,6 +502,10 @@ var Arg = function (str) {
else if (full) {
value = fullMatch[1] ? false : fullMatch[3];
}
else if (chars && chars.length === 1) {
// Only allow `-v-` or `-v+` when option `-v` is alone. Do *not* allow `-cfv-` or `-cfv+`!
value = charMatch[2] ? charMatch[2] === '+' : undefined;
}

return {
str: str,
Expand Down

0 comments on commit 11fbe68

Please sign in to comment.