lib/extern/optparse/lib/optparse.js
function build_rules(filters, arr) {
    var rules = [];
    for(var i=0; i<arr.length; i++) {
        var r = arr[i], rule
        if(!contains_expr(r)) throw OptError('Rule MUST contain an option.');
        switch(r.length) {
            case 1:
                rule = build_rule(filters, r[0]);
                break;
            case 2:
                var expr = LONG_SWITCH_RE.test(r[0]) ? 0 : 1;
                var alias = expr == 0 ? -1 : 0;
                var desc = alias == -1 ? 1 : -1;
                rule = build_rule(filters, r[alias], r[expr], r[desc]);
                break;
            case 3:
                rule = build_rule(filters, r[0], r[1], r[2]);
                break;
            default:
            case 0:
                continue;
        }
        rules.push(rule)
    }
    return rules;
}
function build_rules(filters, arr) {
    var rules = [];
    for(var i=0; i<arr.length; i++) {
        var r = arr[i], rule
        if(!contains_expr(r)) throw OptError('Rule MUST contain an option.');
        switch(r.length) {
            case 1:
                rule = build_rule(filters, r[0]);
                break;
            case 2:
                var expr = LONG_SWITCH_RE.test(r[0]) ? 0 : 1;
                var alias = expr == 0 ? -1 : 0;
                var desc = alias == -1 ? 1 : -1;
                rule = build_rule(filters, r[alias], r[expr], r[desc]);
                break;
            case 3:
                rule = build_rule(filters, r[0], r[1], r[2]);
                break;
            default:
            case 0:
                continue;
        }
        rules.push(rule)
    }
    return rules;
}
function build_rules ( filters , arr ) { var rules = [ ] ; for ( var i = 0 ; i < arr . length ; i ++ ) { var r = arr [ i ] , rule if ( ! contains_expr ( r ) ) throw OptError ( 'Rule MUST contain an option.' ) ; switch ( r . length ) { case 1 : rule = build_rule ( filters , r [ 0 ] ) ; break ; case 2 : var expr = LONG_SWITCH_RE . test ( r [ 0 ] ) ? 0 : 1 ; var alias = expr == 0 ? - 1 : 0 ; var desc = alias == - 1 ? 1 : - 1 ; rule = build_rule ( filters , r [ alias ] , r [ expr ] , r [ desc ] ) ; break ; case 3 : rule = build_rule ( filters , r [ 0 ] , r [ 1 ] , r [ 2 ] ) ; break ; default : case 0 : continue ; } rules . push ( rule ) } return rules ; }
Buildes rules from a switches collection. The switches collection is defined when constructing a new OptionParser object.
Buildes rules from a switches collection . The switches collection is defined when constructing a new OptionParser object .