optparse-js icon indicating copy to clipboard operation
optparse-js copied to clipboard

kvp args

Open wehowski opened this issue 9 years ago • 0 comments

Hello, first good job, thanks.

My arguments look like

    --key="value"

rather than

   -key value

So these changes worked for me:

        while(this._halt == false && (token = tokens.shift())) {
            var p = token.split('=');
             token=p[0];
             var arg = p[1] || true;
              if('string'===typeof arg && '"' === arg.substr(0,1) && '"' === arg.substr(arg.length-1,arg.length)){
                arg = arg.substr(1,arg.length-1);
              }


            if(LONG_SWITCH_RE.test(token) || SHORT_SWITCH_RE.test(token)) {

                // The token is a long or a short switch. Get the corresponding
                // rule, filter and handle it. Pass the switch to the default
                // handler if no rule matched.
                for(var i = 0; i < rules.length; i++) {
                    var rule = rules[i];
                    if(rule.long == token || rule.short == token) {
                        if(rule.filter !== undefined) {

                            if(arg && (!LONG_SWITCH_RE.test(arg) && !SHORT_SWITCH_RE.test(arg))) {

wehowski avatar Jun 28 '16 16:06 wehowski