MCPcopy Index your code
hub / github.com/CSSLint/csslint / cli

Function cli

src/cli/common.js:9–378  ·  view source on GitHub ↗
(api)

Source from the content-addressed store, hash-verified

7/* exported cli */
8
9function cli(api) {
10 "use strict";
11
12 var globalOptions = {
13 "help" : { "format" : "", "description" : "Displays this information." },
14 "format" : { "format" : "<format>", "description" : "Indicate which format to use for output." },
15 "list-rules" : { "format" : "", "description" : "Outputs all of the rules available." },
16 "quiet" : { "format" : "", "description" : "Only output when errors are present." },
17 "errors" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as errors." },
18 "warnings" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as warnings." },
19 "ignore" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to ignore completely." },
20 "exclude-list": { "format" : "<file|dir[,file|dir]+>", "description" : "Indicate which files/directories to exclude from being linted." },
21 "config" : { "format" : "<file>", "description" : "Reads csslint options from specified file." },
22 "version" : { "format" : "", "description" : "Outputs the current version number." }
23 };
24
25 //-------------------------------------------------------------------------
26 // Helper functions
27 //-------------------------------------------------------------------------
28
29 /**
30 * Returns an array of messages for a particular type.
31 * @param messages {Array} Array of CSS Lint messages.
32 * @param type {String} The type of message to filter on.
33 * @return {Array} An array of matching messages.
34 */
35 function pluckByType(messages, type) {
36 return messages.filter(function(message) {
37 return message.type === type;
38 });
39 }
40
41 /**
42 * Returns a ruleset object based on the CLI options.
43 * @param options {Object} The CLI options.
44 * @return {Object} A ruleset object.
45 */
46 function gatherRules(options, ruleset) {
47 var warnings = options.rules || options.warnings,
48 errors = options.errors;
49
50 if (warnings) {
51 ruleset = ruleset || {};
52 warnings.split(",").forEach(function(value) {
53 ruleset[value] = 1;
54 });
55 }
56
57 if (errors) {
58 ruleset = ruleset || {};
59 errors.split(",").forEach(function(value) {
60 ruleset[value] = 2;
61 });
62 }
63
64 return ruleset;
65 }
66

Callers 3

rhino.jsFile · 0.85
node.jsFile · 0.85
wsh.jsFile · 0.85

Calls 6

processArgumentsFunction · 0.85
outputHelpFunction · 0.85
printRulesFunction · 0.85
readConfigDataFunction · 0.85
validateOptionsFunction · 0.85
processFilesFunction · 0.85

Tested by

no test coverage detected