Code coverage report for lib/parser/commands/sort.js

Statements: 100% (38 / 38)      Branches: 75% (3 / 4)      Functions: 100% (5 / 5)      Lines: 100% (35 / 35)      Ignored: none     

All files » lib/parser/commands/ » sort.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 2001 1 1 1 1   1 1 1 1   1   1                                                                                                                                               1                                                                 1                   1           1   1                                                                         1   1 1 1 4 4 4   1   1   1 1 1 1 1 1       1 1 1 1  
var __extends = this.__extends || function (d, b) {
    for (var p in b) Eif (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var $ = require("../utils/optionsParser");
var parserModule = require("../utils/parserData");
var common = require("../utils/init");
var GraphModule = require("../../common/graph");
 
var nullstr = null;
 
var selectors = {
    action: {
        name: 'action',
        description: 'action to exectute',
        options: {
            sort: {
                name: 'sort',
                option: nullstr,
                description: 'sort',
                defaut: true
            },
            check: {
                name: 'check',
                option: 'c',
                description: 'sort by number'
            },
            silentCheck: {
                name: 'quiet check',
                option: 'g',
                description: 'print line numbers on all lines'
            },
            merge: {
                name: 'merge files',
                option: 'm',
                description: 'print line numbers on all lines'
            }
        }
    },
    sort: {
        name: 'sort',
        description: 'sort according to option',
        options: {
            text: {
                name: 'text',
                option: nullstr,
                description: 'sort by text',
                defaut: true
            },
            numeric: {
                name: 'numeric',
                option: 'n',
                description: 'sort by number'
            },
            generalNumeric: {
                name: 'general numeric',
                option: 'g',
                description: 'print line numbers on all lines'
            },
            humanNumeric: {
                name: 'human numeric',
                option: 'h',
                description: 'print line numbers on non empty lines'
            },
            Month: {
                name: 'month',
                option: 'M',
                description: 'print line numbers on non empty lines'
            },
            random: {
                name: 'random',
                option: 'R',
                description: 'print line numbers on non empty lines'
            },
            version: {
                name: 'version',
                option: 'V',
                description: 'print line numbers on non empty lines'
            }
        }
    }
};
 
var flags = {
    reverse: {
        name: "reverse",
        option: 'r',
        description: "print TAB characters like ^I",
        active: false
    },
    unique: {
        name: "unique",
        option: 'u',
        description: "suppress repeated empty output lines",
        active: false
    },
    ignoreCase: {
        name: "ignore case",
        option: 'E',
        description: "print $ after each line",
        active: false
    },
    ignoreNonprinting: {
        name: "ignore non-printing chars",
        option: 'v',
        description: "use ^ and M- notation, except for LFD and TAB",
        active: false
    },
    ignoreLeadingBlanks: {
        name: "ignore leading blanks",
        option: 's',
        description: "suppress repeated empty output lines",
        active: false
    }
};
 
var parameters = {
    key: {
        name: 'key',
        option: 'k',
        type: "string",
        description: "sort via a key",
        defaultValue: ""
    }
};
 
var config = {
    selectors: selectors,
    flags: flags,
    parameters: parameters
};
 
var sortData = new parserModule.ParserData(config);
 
var optionsParser = {
    shortOptions: {
        b: $.switchOn(flags.ignoreLeadingBlanks),
        d: $.ignore,
        f: $.switchOn(flags.ignoreCase),
        g: $.select(selectors.sort, selectors.sort.options.generalNumeric),
        i: $.switchOn(flags.ignoreNonprinting),
        M: $.select(selectors.sort, selectors.sort.options.Month),
        h: $.select(selectors.sort, selectors.sort.options.humanNumeric),
        n: $.select(selectors.sort, selectors.sort.options.numeric),
        R: $.select(selectors.sort, selectors.sort.options.random),
        r: $.switchOn(flags.reverse),
        V: $.select(selectors.sort, selectors.sort.options.version),
        c: $.select(selectors.action, selectors.action.options.check),
        C: $.select(selectors.action, selectors.action.options.silentCheck),
        k: $.setParameter(parameters.key.name),
        m: $.select(selectors.action, selectors.action.options.merge),
        o: $.ignore,
        s: $.ignore,
        S: $.ignore,
        t: $.ignore,
        T: $.ignore,
        u: $.switchOn(flags.unique),
        z: $.ignore
    },
    longOptions: {
        "ignore-leading-blanks": $.sameAs('b'),
        "dictionary-order": $.ignore,
        "ignore-case": $.sameAs('f'),
        "general-numeric": $.sameAs('g'),
        "ignore-nonprinting": $.sameAs('i'),
        "month-sort": $.sameAs('M'),
        "human-numeric-sort": $.sameAs('h'),
        "numeric-sort": $.sameAs('n'),
        "unique": $.sameAs('u')
    }
};
$.generate(optionsParser);
 
var SortComponent = (function (_super) {
    __extends(SortComponent, _super);
    function SortComponent() {
        _super.apply(this, arguments);
        this.exec = "sort";
        this.files = [];
    }
    return SortComponent;
})(GraphModule.CommandComponent);
exports.SortComponent = SortComponent;
 
function defaultComponentData() {
    var component = new SortComponent();
    component.selectors = sortData.componentSelectors;
    component.flags = sortData.componentFlags;
    component.parameters = sortData.componentParameters;
    return component;
}
;
 
exports.parseCommand = common.commonParseCommand(optionsParser, defaultComponentData);
exports.parseComponent = common.commonParseComponent(sortData.flagOptions, sortData.selectorOptions, sortData.parameterOptions);
exports.VisualSelectorOptions = sortData.visualSelectorOptions;
exports.componentClass = SortComponent;