Skip to content

kvp args #21

Open
Open
@wehowski

Description

@wehowski

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))) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions