ea01ffabe2606f3fae25d510d306064a09daa50f.svn-base
962 Bytes
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
/*
* grunt
* http://gruntjs.com/
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
*/
// The actual option data.
var data = {};
// Get or set an option value.
var option = module.exports = function(key, value) {
var no = key.match(/^no-(.+)$/);
if (arguments.length === 2) {
return (data[key] = value);
} else if (no) {
return data[no[1]] === false;
} else {
return data[key];
}
};
// Initialize option data.
option.init = function(obj) {
return (data = obj || {});
};
// List of options as flags.
option.flags = function() {
return Object.keys(data).filter(function(key) {
// Don't display empty arrays.
return !(Array.isArray(data[key]) && data[key].length === 0);
}).map(function(key) {
var val = data[key];
return '--' + (val === false ? 'no-' : '') + key +
(typeof val === 'boolean' ? '' : '=' + val);
});
};