Commit d3bc79c79662ef926ed90cea8226813961a5b6fb
1 parent
5fb9eca4
remove node_modules
Showing
73 changed files
with
0 additions
and
4691 deletions
Too many changes to show.
To preserve performance only 73 of 3766 files are displayed.
images/node_modules/.bin/cake deleted
120000 → 0
images/node_modules/.bin/coffee deleted
120000 → 0
images/node_modules/.bin/esparse deleted
120000 → 0
images/node_modules/.bin/esvalidate deleted
120000 → 0
images/node_modules/.bin/grunt-glue deleted
120000 → 0
images/node_modules/.bin/gulp deleted
120000 → 0
images/node_modules/.bin/js-yaml deleted
120000 → 0
images/node_modules/.bin/mkdirp deleted
120000 → 0
images/node_modules/.bin/nopt deleted
120000 → 0
images/node_modules/.bin/rimraf deleted
120000 → 0
images/node_modules/.bin/semver deleted
120000 → 0
images/node_modules/.bin/strip-indent deleted
120000 → 0
images/node_modules/.bin/user-home deleted
120000 → 0
images/node_modules/.bin/which deleted
120000 → 0
images/node_modules/abbrev/.npmignore deleted
100644 → 0
images/node_modules/abbrev/.travis.yml deleted
100644 → 0
images/node_modules/abbrev/CONTRIBUTING.md deleted
100644 → 0
images/node_modules/abbrev/LICENSE deleted
100644 → 0
1 | -The ISC License | |
2 | - | |
3 | -Copyright (c) Isaac Z. Schlueter and Contributors | |
4 | - | |
5 | -Permission to use, copy, modify, and/or distribute this software for any | |
6 | -purpose with or without fee is hereby granted, provided that the above | |
7 | -copyright notice and this permission notice appear in all copies. | |
8 | - | |
9 | -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
10 | -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
11 | -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
12 | -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
13 | -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
14 | -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | |
15 | -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
images/node_modules/abbrev/README.md deleted
100644 → 0
1 | -# abbrev-js | |
2 | - | |
3 | -Just like [ruby's Abbrev](http://apidock.com/ruby/Abbrev). | |
4 | - | |
5 | -Usage: | |
6 | - | |
7 | - var abbrev = require("abbrev"); | |
8 | - abbrev("foo", "fool", "folding", "flop"); | |
9 | - | |
10 | - // returns: | |
11 | - { fl: 'flop' | |
12 | - , flo: 'flop' | |
13 | - , flop: 'flop' | |
14 | - , fol: 'folding' | |
15 | - , fold: 'folding' | |
16 | - , foldi: 'folding' | |
17 | - , foldin: 'folding' | |
18 | - , folding: 'folding' | |
19 | - , foo: 'foo' | |
20 | - , fool: 'fool' | |
21 | - } | |
22 | - | |
23 | -This is handy for command-line scripts, or other cases where you want to be able to accept shorthands. |
images/node_modules/abbrev/abbrev.js deleted
100644 → 0
1 | - | |
2 | -module.exports = exports = abbrev.abbrev = abbrev | |
3 | - | |
4 | -abbrev.monkeyPatch = monkeyPatch | |
5 | - | |
6 | -function monkeyPatch () { | |
7 | - Object.defineProperty(Array.prototype, 'abbrev', { | |
8 | - value: function () { return abbrev(this) }, | |
9 | - enumerable: false, configurable: true, writable: true | |
10 | - }) | |
11 | - | |
12 | - Object.defineProperty(Object.prototype, 'abbrev', { | |
13 | - value: function () { return abbrev(Object.keys(this)) }, | |
14 | - enumerable: false, configurable: true, writable: true | |
15 | - }) | |
16 | -} | |
17 | - | |
18 | -function abbrev (list) { | |
19 | - if (arguments.length !== 1 || !Array.isArray(list)) { | |
20 | - list = Array.prototype.slice.call(arguments, 0) | |
21 | - } | |
22 | - for (var i = 0, l = list.length, args = [] ; i < l ; i ++) { | |
23 | - args[i] = typeof list[i] === "string" ? list[i] : String(list[i]) | |
24 | - } | |
25 | - | |
26 | - // sort them lexicographically, so that they're next to their nearest kin | |
27 | - args = args.sort(lexSort) | |
28 | - | |
29 | - // walk through each, seeing how much it has in common with the next and previous | |
30 | - var abbrevs = {} | |
31 | - , prev = "" | |
32 | - for (var i = 0, l = args.length ; i < l ; i ++) { | |
33 | - var current = args[i] | |
34 | - , next = args[i + 1] || "" | |
35 | - , nextMatches = true | |
36 | - , prevMatches = true | |
37 | - if (current === next) continue | |
38 | - for (var j = 0, cl = current.length ; j < cl ; j ++) { | |
39 | - var curChar = current.charAt(j) | |
40 | - nextMatches = nextMatches && curChar === next.charAt(j) | |
41 | - prevMatches = prevMatches && curChar === prev.charAt(j) | |
42 | - if (!nextMatches && !prevMatches) { | |
43 | - j ++ | |
44 | - break | |
45 | - } | |
46 | - } | |
47 | - prev = current | |
48 | - if (j === cl) { | |
49 | - abbrevs[current] = current | |
50 | - continue | |
51 | - } | |
52 | - for (var a = current.substr(0, j) ; j <= cl ; j ++) { | |
53 | - abbrevs[a] = current | |
54 | - a += current.charAt(j) | |
55 | - } | |
56 | - } | |
57 | - return abbrevs | |
58 | -} | |
59 | - | |
60 | -function lexSort (a, b) { | |
61 | - return a === b ? 0 : a > b ? 1 : -1 | |
62 | -} |
images/node_modules/abbrev/package.json deleted
100644 → 0
1 | -{ | |
2 | - "_args": [ | |
3 | - [ | |
4 | - "abbrev@1", | |
5 | - "/Users/sam/Documents/dili_git_project/static-pnr/images/2.3.0/node_modules/nopt" | |
6 | - ] | |
7 | - ], | |
8 | - "_from": "abbrev@>=1.0.0 <2.0.0", | |
9 | - "_id": "abbrev@1.0.7", | |
10 | - "_inCache": true, | |
11 | - "_installable": true, | |
12 | - "_location": "/abbrev", | |
13 | - "_nodeVersion": "2.0.1", | |
14 | - "_npmUser": { | |
15 | - "email": "isaacs@npmjs.com", | |
16 | - "name": "isaacs" | |
17 | - }, | |
18 | - "_npmVersion": "2.10.1", | |
19 | - "_phantomChildren": {}, | |
20 | - "_requested": { | |
21 | - "name": "abbrev", | |
22 | - "raw": "abbrev@1", | |
23 | - "rawSpec": "1", | |
24 | - "scope": null, | |
25 | - "spec": ">=1.0.0 <2.0.0", | |
26 | - "type": "range" | |
27 | - }, | |
28 | - "_requiredBy": [ | |
29 | - "/nopt" | |
30 | - ], | |
31 | - "_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz", | |
32 | - "_shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", | |
33 | - "_shrinkwrap": null, | |
34 | - "_spec": "abbrev@1", | |
35 | - "_where": "/Users/sam/Documents/dili_git_project/static-pnr/images/2.3.0/node_modules/nopt", | |
36 | - "author": { | |
37 | - "email": "i@izs.me", | |
38 | - "name": "Isaac Z. Schlueter" | |
39 | - }, | |
40 | - "bugs": { | |
41 | - "url": "https://github.com/isaacs/abbrev-js/issues" | |
42 | - }, | |
43 | - "dependencies": {}, | |
44 | - "description": "Like ruby's abbrev module, but in js", | |
45 | - "devDependencies": { | |
46 | - "tap": "^1.2.0" | |
47 | - }, | |
48 | - "directories": {}, | |
49 | - "dist": { | |
50 | - "shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", | |
51 | - "tarball": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz" | |
52 | - }, | |
53 | - "gitHead": "821d09ce7da33627f91bbd8ed631497ed6f760c2", | |
54 | - "homepage": "https://github.com/isaacs/abbrev-js#readme", | |
55 | - "license": "ISC", | |
56 | - "main": "abbrev.js", | |
57 | - "maintainers": [ | |
58 | - { | |
59 | - "name": "isaacs", | |
60 | - "email": "i@izs.me" | |
61 | - } | |
62 | - ], | |
63 | - "name": "abbrev", | |
64 | - "optionalDependencies": {}, | |
65 | - "readme": "ERROR: No README data found!", | |
66 | - "repository": { | |
67 | - "type": "git", | |
68 | - "url": "git+ssh://git@github.com/isaacs/abbrev-js.git" | |
69 | - }, | |
70 | - "scripts": { | |
71 | - "test": "tap test.js --cov" | |
72 | - }, | |
73 | - "version": "1.0.7" | |
74 | -} |
images/node_modules/abbrev/test.js deleted
100644 → 0
1 | -var abbrev = require('./abbrev.js') | |
2 | -var assert = require("assert") | |
3 | -var util = require("util") | |
4 | - | |
5 | -console.log("TAP version 13") | |
6 | -var count = 0 | |
7 | - | |
8 | -function test (list, expect) { | |
9 | - count++ | |
10 | - var actual = abbrev(list) | |
11 | - assert.deepEqual(actual, expect, | |
12 | - "abbrev("+util.inspect(list)+") === " + util.inspect(expect) + "\n"+ | |
13 | - "actual: "+util.inspect(actual)) | |
14 | - actual = abbrev.apply(exports, list) | |
15 | - assert.deepEqual(abbrev.apply(exports, list), expect, | |
16 | - "abbrev("+list.map(JSON.stringify).join(",")+") === " + util.inspect(expect) + "\n"+ | |
17 | - "actual: "+util.inspect(actual)) | |
18 | - console.log('ok - ' + list.join(' ')) | |
19 | -} | |
20 | - | |
21 | -test([ "ruby", "ruby", "rules", "rules", "rules" ], | |
22 | -{ rub: 'ruby' | |
23 | -, ruby: 'ruby' | |
24 | -, rul: 'rules' | |
25 | -, rule: 'rules' | |
26 | -, rules: 'rules' | |
27 | -}) | |
28 | -test(["fool", "foom", "pool", "pope"], | |
29 | -{ fool: 'fool' | |
30 | -, foom: 'foom' | |
31 | -, poo: 'pool' | |
32 | -, pool: 'pool' | |
33 | -, pop: 'pope' | |
34 | -, pope: 'pope' | |
35 | -}) | |
36 | -test(["a", "ab", "abc", "abcd", "abcde", "acde"], | |
37 | -{ a: 'a' | |
38 | -, ab: 'ab' | |
39 | -, abc: 'abc' | |
40 | -, abcd: 'abcd' | |
41 | -, abcde: 'abcde' | |
42 | -, ac: 'acde' | |
43 | -, acd: 'acde' | |
44 | -, acde: 'acde' | |
45 | -}) | |
46 | - | |
47 | -console.log("1..%d", count) |
images/node_modules/ansi-regex/index.js deleted
100644 → 0
images/node_modules/ansi-regex/license deleted
100644 → 0
1 | -The MIT License (MIT) | |
2 | - | |
3 | -Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | |
4 | - | |
5 | -Permission is hereby granted, free of charge, to any person obtaining a copy | |
6 | -of this software and associated documentation files (the "Software"), to deal | |
7 | -in the Software without restriction, including without limitation the rights | |
8 | -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
9 | -copies of the Software, and to permit persons to whom the Software is | |
10 | -furnished to do so, subject to the following conditions: | |
11 | - | |
12 | -The above copyright notice and this permission notice shall be included in | |
13 | -all copies or substantial portions of the Software. | |
14 | - | |
15 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
18 | -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 | -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
21 | -THE SOFTWARE. |
images/node_modules/ansi-regex/package.json deleted
100644 → 0
1 | -{ | |
2 | - "_args": [ | |
3 | - [ | |
4 | - "ansi-regex@^2.0.0", | |
5 | - "/Users/sam/Documents/dili_git_project/static-pnr/images/2.3.0/node_modules/has-ansi" | |
6 | - ] | |
7 | - ], | |
8 | - "_from": "ansi-regex@>=2.0.0 <3.0.0", | |
9 | - "_id": "ansi-regex@2.0.0", | |
10 | - "_inCache": true, | |
11 | - "_installable": true, | |
12 | - "_location": "/ansi-regex", | |
13 | - "_nodeVersion": "0.12.5", | |
14 | - "_npmUser": { | |
15 | - "email": "sindresorhus@gmail.com", | |
16 | - "name": "sindresorhus" | |
17 | - }, | |
18 | - "_npmVersion": "2.11.2", | |
19 | - "_phantomChildren": {}, | |
20 | - "_requested": { | |
21 | - "name": "ansi-regex", | |
22 | - "raw": "ansi-regex@^2.0.0", | |
23 | - "rawSpec": "^2.0.0", | |
24 | - "scope": null, | |
25 | - "spec": ">=2.0.0 <3.0.0", | |
26 | - "type": "range" | |
27 | - }, | |
28 | - "_requiredBy": [ | |
29 | - "/has-ansi", | |
30 | - "/strip-ansi" | |
31 | - ], | |
32 | - "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz", | |
33 | - "_shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107", | |
34 | - "_shrinkwrap": null, | |
35 | - "_spec": "ansi-regex@^2.0.0", | |
36 | - "_where": "/Users/sam/Documents/dili_git_project/static-pnr/images/2.3.0/node_modules/has-ansi", | |
37 | - "author": { | |
38 | - "email": "sindresorhus@gmail.com", | |
39 | - "name": "Sindre Sorhus", | |
40 | - "url": "sindresorhus.com" | |
41 | - }, | |
42 | - "bugs": { | |
43 | - "url": "https://github.com/sindresorhus/ansi-regex/issues" | |
44 | - }, | |
45 | - "dependencies": {}, | |
46 | - "description": "Regular expression for matching ANSI escape codes", | |
47 | - "devDependencies": { | |
48 | - "mocha": "*" | |
49 | - }, | |
50 | - "directories": {}, | |
51 | - "dist": { | |
52 | - "shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107", | |
53 | - "tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz" | |
54 | - }, | |
55 | - "engines": { | |
56 | - "node": ">=0.10.0" | |
57 | - }, | |
58 | - "files": [ | |
59 | - "index.js" | |
60 | - ], | |
61 | - "gitHead": "57c3f2941a73079fa8b081e02a522e3d29913e2f", | |
62 | - "homepage": "https://github.com/sindresorhus/ansi-regex", | |
63 | - "keywords": [ | |
64 | - "256", | |
65 | - "ansi", | |
66 | - "cli", | |
67 | - "color", | |
68 | - "colors", | |
69 | - "colour", | |
70 | - "command-line", | |
71 | - "console", | |
72 | - "escape", | |
73 | - "find", | |
74 | - "formatting", | |
75 | - "match", | |
76 | - "pattern", | |
77 | - "re", | |
78 | - "regex", | |
79 | - "regexp", | |
80 | - "rgb", | |
81 | - "shell", | |
82 | - "string", | |
83 | - "styles", | |
84 | - "terminal", | |
85 | - "test", | |
86 | - "text", | |
87 | - "tty", | |
88 | - "xterm" | |
89 | - ], | |
90 | - "license": "MIT", | |
91 | - "maintainers": [ | |
92 | - { | |
93 | - "name": "sindresorhus", | |
94 | - "email": "sindresorhus@gmail.com" | |
95 | - }, | |
96 | - { | |
97 | - "name": "jbnicolai", | |
98 | - "email": "jappelman@xebia.com" | |
99 | - } | |
100 | - ], | |
101 | - "name": "ansi-regex", | |
102 | - "optionalDependencies": {}, | |
103 | - "readme": "ERROR: No README data found!", | |
104 | - "repository": { | |
105 | - "type": "git", | |
106 | - "url": "git+https://github.com/sindresorhus/ansi-regex.git" | |
107 | - }, | |
108 | - "scripts": { | |
109 | - "test": "mocha test/test.js", | |
110 | - "view-supported": "node test/viewCodes.js" | |
111 | - }, | |
112 | - "version": "2.0.0" | |
113 | -} |
images/node_modules/ansi-regex/readme.md deleted
100644 → 0
1 | -# ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex) | |
2 | - | |
3 | -> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) | |
4 | - | |
5 | - | |
6 | -## Install | |
7 | - | |
8 | -``` | |
9 | -$ npm install --save ansi-regex | |
10 | -``` | |
11 | - | |
12 | - | |
13 | -## Usage | |
14 | - | |
15 | -```js | |
16 | -var ansiRegex = require('ansi-regex'); | |
17 | - | |
18 | -ansiRegex().test('\u001b[4mcake\u001b[0m'); | |
19 | -//=> true | |
20 | - | |
21 | -ansiRegex().test('cake'); | |
22 | -//=> false | |
23 | - | |
24 | -'\u001b[4mcake\u001b[0m'.match(ansiRegex()); | |
25 | -//=> ['\u001b[4m', '\u001b[0m'] | |
26 | -``` | |
27 | - | |
28 | - | |
29 | -## License | |
30 | - | |
31 | -MIT © [Sindre Sorhus](http://sindresorhus.com) |
images/node_modules/ansi-styles/index.js deleted
100644 → 0
1 | -'use strict'; | |
2 | - | |
3 | -function assembleStyles () { | |
4 | - var styles = { | |
5 | - modifiers: { | |
6 | - reset: [0, 0], | |
7 | - bold: [1, 22], // 21 isn't widely supported and 22 does the same thing | |
8 | - dim: [2, 22], | |
9 | - italic: [3, 23], | |
10 | - underline: [4, 24], | |
11 | - inverse: [7, 27], | |
12 | - hidden: [8, 28], | |
13 | - strikethrough: [9, 29] | |
14 | - }, | |
15 | - colors: { | |
16 | - black: [30, 39], | |
17 | - red: [31, 39], | |
18 | - green: [32, 39], | |
19 | - yellow: [33, 39], | |
20 | - blue: [34, 39], | |
21 | - magenta: [35, 39], | |
22 | - cyan: [36, 39], | |
23 | - white: [37, 39], | |
24 | - gray: [90, 39] | |
25 | - }, | |
26 | - bgColors: { | |
27 | - bgBlack: [40, 49], | |
28 | - bgRed: [41, 49], | |
29 | - bgGreen: [42, 49], | |
30 | - bgYellow: [43, 49], | |
31 | - bgBlue: [44, 49], | |
32 | - bgMagenta: [45, 49], | |
33 | - bgCyan: [46, 49], | |
34 | - bgWhite: [47, 49] | |
35 | - } | |
36 | - }; | |
37 | - | |
38 | - // fix humans | |
39 | - styles.colors.grey = styles.colors.gray; | |
40 | - | |
41 | - Object.keys(styles).forEach(function (groupName) { | |
42 | - var group = styles[groupName]; | |
43 | - | |
44 | - Object.keys(group).forEach(function (styleName) { | |
45 | - var style = group[styleName]; | |
46 | - | |
47 | - styles[styleName] = group[styleName] = { | |
48 | - open: '\u001b[' + style[0] + 'm', | |
49 | - close: '\u001b[' + style[1] + 'm' | |
50 | - }; | |
51 | - }); | |
52 | - | |
53 | - Object.defineProperty(styles, groupName, { | |
54 | - value: group, | |
55 | - enumerable: false | |
56 | - }); | |
57 | - }); | |
58 | - | |
59 | - return styles; | |
60 | -} | |
61 | - | |
62 | -Object.defineProperty(module, 'exports', { | |
63 | - enumerable: true, | |
64 | - get: assembleStyles | |
65 | -}); |
images/node_modules/ansi-styles/license deleted
100644 → 0
1 | -The MIT License (MIT) | |
2 | - | |
3 | -Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | |
4 | - | |
5 | -Permission is hereby granted, free of charge, to any person obtaining a copy | |
6 | -of this software and associated documentation files (the "Software"), to deal | |
7 | -in the Software without restriction, including without limitation the rights | |
8 | -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
9 | -copies of the Software, and to permit persons to whom the Software is | |
10 | -furnished to do so, subject to the following conditions: | |
11 | - | |
12 | -The above copyright notice and this permission notice shall be included in | |
13 | -all copies or substantial portions of the Software. | |
14 | - | |
15 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
18 | -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 | -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
21 | -THE SOFTWARE. |
images/node_modules/ansi-styles/package.json deleted
100644 → 0
1 | -{ | |
2 | - "_args": [ | |
3 | - [ | |
4 | - "ansi-styles@^2.1.0", | |
5 | - "/Users/sam/Documents/dili_git_project/static-pnr/images/2.3.0/node_modules/chalk" | |
6 | - ] | |
7 | - ], | |
8 | - "_from": "ansi-styles@>=2.1.0 <3.0.0", | |
9 | - "_id": "ansi-styles@2.1.0", | |
10 | - "_inCache": true, | |
11 | - "_installable": true, | |
12 | - "_location": "/ansi-styles", | |
13 | - "_nodeVersion": "0.12.4", | |
14 | - "_npmUser": { | |
15 | - "email": "jappelman@xebia.com", | |
16 | - "name": "jbnicolai" | |
17 | - }, | |
18 | - "_npmVersion": "2.10.1", | |
19 | - "_phantomChildren": {}, | |
20 | - "_requested": { | |
21 | - "name": "ansi-styles", | |
22 | - "raw": "ansi-styles@^2.1.0", | |
23 | - "rawSpec": "^2.1.0", | |
24 | - "scope": null, | |
25 | - "spec": ">=2.1.0 <3.0.0", | |
26 | - "type": "range" | |
27 | - }, | |
28 | - "_requiredBy": [ | |
29 | - "/chalk" | |
30 | - ], | |
31 | - "_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz", | |
32 | - "_shasum": "990f747146927b559a932bf92959163d60c0d0e2", | |
33 | - "_shrinkwrap": null, | |
34 | - "_spec": "ansi-styles@^2.1.0", | |
35 | - "_where": "/Users/sam/Documents/dili_git_project/static-pnr/images/2.3.0/node_modules/chalk", | |
36 | - "author": { | |
37 | - "email": "sindresorhus@gmail.com", | |
38 | - "name": "Sindre Sorhus", | |
39 | - "url": "sindresorhus.com" | |
40 | - }, | |
41 | - "bugs": { | |
42 | - "url": "https://github.com/chalk/ansi-styles/issues" | |
43 | - }, | |
44 | - "dependencies": {}, | |
45 | - "description": "ANSI escape codes for styling strings in the terminal", | |
46 | - "devDependencies": { | |
47 | - "mocha": "*" | |
48 | - }, | |
49 | - "directories": {}, | |
50 | - "dist": { | |
51 | - "shasum": "990f747146927b559a932bf92959163d60c0d0e2", | |
52 | - "tarball": "http://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz" | |
53 | - }, | |
54 | - "engines": { | |
55 | - "node": ">=0.10.0" | |
56 | - }, | |
57 | - "files": [ | |
58 | - "index.js" | |
59 | - ], | |
60 | - "gitHead": "18421cbe4a2d93359ec2599a894f704be126d066", | |
61 | - "homepage": "https://github.com/chalk/ansi-styles", | |
62 | - "keywords": [ | |
63 | - "256", | |
64 | - "ansi", | |
65 | - "cli", | |
66 | - "color", | |
67 | - "colors", | |
68 | - "colour", | |
69 | - "command-line", | |
70 | - "console", | |
71 | - "escape", | |
72 | - "formatting", | |
73 | - "log", | |
74 | - "logging", | |
75 | - "rgb", | |
76 | - "shell", | |
77 | - "string", | |
78 | - "styles", | |
79 | - "terminal", | |
80 | - "text", | |
81 | - "tty", | |
82 | - "xterm" | |
83 | - ], | |
84 | - "license": "MIT", | |
85 | - "maintainers": [ | |
86 | - { | |
87 | - "name": "sindresorhus", | |
88 | - "email": "sindresorhus@gmail.com" | |
89 | - }, | |
90 | - { | |
91 | - "name": "jbnicolai", | |
92 | - "email": "jappelman@xebia.com" | |
93 | - } | |
94 | - ], | |
95 | - "name": "ansi-styles", | |
96 | - "optionalDependencies": {}, | |
97 | - "readme": "ERROR: No README data found!", | |
98 | - "repository": { | |
99 | - "type": "git", | |
100 | - "url": "git+https://github.com/chalk/ansi-styles.git" | |
101 | - }, | |
102 | - "scripts": { | |
103 | - "test": "mocha" | |
104 | - }, | |
105 | - "version": "2.1.0" | |
106 | -} |
images/node_modules/ansi-styles/readme.md deleted
100644 → 0
1 | -# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles) | |
2 | - | |
3 | -> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal | |
4 | - | |
5 | -You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings. | |
6 | - | |
7 | -![](screenshot.png) | |
8 | - | |
9 | - | |
10 | -## Install | |
11 | - | |
12 | -``` | |
13 | -$ npm install --save ansi-styles | |
14 | -``` | |
15 | - | |
16 | - | |
17 | -## Usage | |
18 | - | |
19 | -```js | |
20 | -var ansi = require('ansi-styles'); | |
21 | - | |
22 | -console.log(ansi.green.open + 'Hello world!' + ansi.green.close); | |
23 | -``` | |
24 | - | |
25 | - | |
26 | -## API | |
27 | - | |
28 | -Each style has an `open` and `close` property. | |
29 | - | |
30 | - | |
31 | -## Styles | |
32 | - | |
33 | -### Modifiers | |
34 | - | |
35 | -- `reset` | |
36 | -- `bold` | |
37 | -- `dim` | |
38 | -- `italic` *(not widely supported)* | |
39 | -- `underline` | |
40 | -- `inverse` | |
41 | -- `hidden` | |
42 | -- `strikethrough` *(not widely supported)* | |
43 | - | |
44 | -### Colors | |
45 | - | |
46 | -- `black` | |
47 | -- `red` | |
48 | -- `green` | |
49 | -- `yellow` | |
50 | -- `blue` | |
51 | -- `magenta` | |
52 | -- `cyan` | |
53 | -- `white` | |
54 | -- `gray` | |
55 | - | |
56 | -### Background colors | |
57 | - | |
58 | -- `bgBlack` | |
59 | -- `bgRed` | |
60 | -- `bgGreen` | |
61 | -- `bgYellow` | |
62 | -- `bgBlue` | |
63 | -- `bgMagenta` | |
64 | -- `bgCyan` | |
65 | -- `bgWhite` | |
66 | - | |
67 | - | |
68 | -## Advanced usage | |
69 | - | |
70 | -By default you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module. | |
71 | - | |
72 | -- `ansi.modifiers` | |
73 | -- `ansi.colors` | |
74 | -- `ansi.bgColors` | |
75 | - | |
76 | - | |
77 | -###### Example | |
78 | - | |
79 | -```js | |
80 | -console.log(ansi.colors.green.open); | |
81 | -``` | |
82 | - | |
83 | - | |
84 | -## License | |
85 | - | |
86 | -MIT © [Sindre Sorhus](http://sindresorhus.com) |
images/node_modules/archy/.travis.yml deleted
100644 → 0
images/node_modules/archy/LICENSE deleted
100644 → 0
1 | -This software is released under the MIT license: | |
2 | - | |
3 | -Permission is hereby granted, free of charge, to any person obtaining a copy of | |
4 | -this software and associated documentation files (the "Software"), to deal in | |
5 | -the Software without restriction, including without limitation the rights to | |
6 | -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
7 | -the Software, and to permit persons to whom the Software is furnished to do so, | |
8 | -subject to the following conditions: | |
9 | - | |
10 | -The above copyright notice and this permission notice shall be included in all | |
11 | -copies or substantial portions of the Software. | |
12 | - | |
13 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
14 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | |
15 | -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | |
16 | -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | |
17 | -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
18 | -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
images/node_modules/archy/examples/beep.js deleted
100644 → 0
1 | -var archy = require('../'); | |
2 | -var s = archy({ | |
3 | - label : 'beep', | |
4 | - nodes : [ | |
5 | - 'ity', | |
6 | - { | |
7 | - label : 'boop', | |
8 | - nodes : [ | |
9 | - { | |
10 | - label : 'o_O', | |
11 | - nodes : [ | |
12 | - { | |
13 | - label : 'oh', | |
14 | - nodes : [ 'hello', 'puny' ] | |
15 | - }, | |
16 | - 'human' | |
17 | - ] | |
18 | - }, | |
19 | - 'party\ntime!' | |
20 | - ] | |
21 | - } | |
22 | - ] | |
23 | -}); | |
24 | -console.log(s); |
images/node_modules/archy/examples/multi_line.js deleted
100644 → 0
1 | -var archy = require('../'); | |
2 | - | |
3 | -var s = archy({ | |
4 | - label : 'beep\none\ntwo', | |
5 | - nodes : [ | |
6 | - 'ity', | |
7 | - { | |
8 | - label : 'boop', | |
9 | - nodes : [ | |
10 | - { | |
11 | - label : 'o_O\nwheee', | |
12 | - nodes : [ | |
13 | - { | |
14 | - label : 'oh', | |
15 | - nodes : [ 'hello', 'puny\nmeat' ] | |
16 | - }, | |
17 | - 'creature' | |
18 | - ] | |
19 | - }, | |
20 | - 'party\ntime!' | |
21 | - ] | |
22 | - } | |
23 | - ] | |
24 | -}); | |
25 | -console.log(s); |
images/node_modules/archy/index.js deleted
100644 → 0
1 | -module.exports = function archy (obj, prefix, opts) { | |
2 | - if (prefix === undefined) prefix = ''; | |
3 | - if (!opts) opts = {}; | |
4 | - var chr = function (s) { | |
5 | - var chars = { | |
6 | - '│' : '|', | |
7 | - '└' : '`', | |
8 | - '├' : '+', | |
9 | - '─' : '-', | |
10 | - '┬' : '-' | |
11 | - }; | |
12 | - return opts.unicode === false ? chars[s] : s; | |
13 | - }; | |
14 | - | |
15 | - if (typeof obj === 'string') obj = { label : obj }; | |
16 | - | |
17 | - var nodes = obj.nodes || []; | |
18 | - var lines = (obj.label || '').split('\n'); | |
19 | - var splitter = '\n' + prefix + (nodes.length ? chr('│') : ' ') + ' '; | |
20 | - | |
21 | - return prefix | |
22 | - + lines.join(splitter) + '\n' | |
23 | - + nodes.map(function (node, ix) { | |
24 | - var last = ix === nodes.length - 1; | |
25 | - var more = node.nodes && node.nodes.length; | |
26 | - var prefix_ = prefix + (last ? ' ' : chr('│')) + ' '; | |
27 | - | |
28 | - return prefix | |
29 | - + (last ? chr('└') : chr('├')) + chr('─') | |
30 | - + (more ? chr('┬') : chr('─')) + ' ' | |
31 | - + archy(node, prefix_, opts).slice(prefix.length + 2) | |
32 | - ; | |
33 | - }).join('') | |
34 | - ; | |
35 | -}; |
images/node_modules/archy/package.json deleted
100644 → 0
1 | -{ | |
2 | - "_args": [ | |
3 | - [ | |
4 | - "archy@^1.0.0", | |
5 | - "/Users/sam/Documents/dili_git_project/static-pnr/images/2.3.0/node_modules/gulp" | |
6 | - ] | |
7 | - ], | |
8 | - "_from": "archy@>=1.0.0 <2.0.0", | |
9 | - "_id": "archy@1.0.0", | |
10 | - "_inCache": true, | |
11 | - "_installable": true, | |
12 | - "_location": "/archy", | |
13 | - "_npmUser": { | |
14 | - "email": "mail@substack.net", | |
15 | - "name": "substack" | |
16 | - }, | |
17 | - "_npmVersion": "1.4.25", | |
18 | - "_phantomChildren": {}, | |
19 | - "_requested": { | |
20 | - "name": "archy", | |
21 | - "raw": "archy@^1.0.0", | |
22 | - "rawSpec": "^1.0.0", | |
23 | - "scope": null, | |
24 | - "spec": ">=1.0.0 <2.0.0", | |
25 | - "type": "range" | |
26 | - }, | |
27 | - "_requiredBy": [ | |
28 | - "/gulp" | |
29 | - ], | |
30 | - "_resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", | |
31 | - "_shasum": "f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40", | |
32 | - "_shrinkwrap": null, | |
33 | - "_spec": "archy@^1.0.0", | |
34 | - "_where": "/Users/sam/Documents/dili_git_project/static-pnr/images/2.3.0/node_modules/gulp", | |
35 | - "author": { | |
36 | - "email": "mail@substack.net", | |
37 | - "name": "James Halliday", | |
38 | - "url": "http://substack.net" | |
39 | - }, | |
40 | - "bugs": { | |
41 | - "url": "https://github.com/substack/node-archy/issues" | |
42 | - }, | |
43 | - "dependencies": {}, | |
44 | - "description": "render nested hierarchies `npm ls` style with unicode pipes", | |
45 | - "devDependencies": { | |
46 | - "tap": "~0.3.3", | |
47 | - "tape": "~0.1.1" | |
48 | - }, | |
49 | - "directories": {}, | |
50 | - "dist": { | |
51 | - "shasum": "f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40", | |
52 | - "tarball": "http://registry.npmjs.org/archy/-/archy-1.0.0.tgz" | |
53 | - }, | |
54 | - "gitHead": "30223c16191e877bf027b15b12daf077b9b55b84", | |
55 | - "homepage": "https://github.com/substack/node-archy", | |
56 | - "keywords": [ | |
57 | - "hierarchy", | |
58 | - "npm ls", | |
59 | - "pretty", | |
60 | - "print", | |
61 | - "unicode" | |
62 | - ], | |
63 | - "license": "MIT", | |
64 | - "main": "index.js", | |
65 | - "maintainers": [ | |
66 | - { | |
67 | - "name": "substack", | |
68 | - "email": "mail@substack.net" | |
69 | - } | |
70 | - ], | |
71 | - "name": "archy", | |
72 | - "optionalDependencies": {}, | |
73 | - "readme": "ERROR: No README data found!", | |
74 | - "repository": { | |
75 | - "type": "git", | |
76 | - "url": "git+ssh://git@github.com/substack/node-archy.git" | |
77 | - }, | |
78 | - "scripts": { | |
79 | - "test": "tap test" | |
80 | - }, | |
81 | - "testling": { | |
82 | - "browsers": { | |
83 | - "chrome": [ | |
84 | - "20.0" | |
85 | - ], | |
86 | - "firefox": [ | |
87 | - "10.0", | |
88 | - "15.0" | |
89 | - ], | |
90 | - "iexplore": [ | |
91 | - "6.0", | |
92 | - "7.0", | |
93 | - "8.0", | |
94 | - "9.0" | |
95 | - ], | |
96 | - "opera": [ | |
97 | - "12.0" | |
98 | - ], | |
99 | - "safari": [ | |
100 | - "5.1" | |
101 | - ] | |
102 | - }, | |
103 | - "files": "test/*.js" | |
104 | - }, | |
105 | - "version": "1.0.0" | |
106 | -} |
images/node_modules/archy/readme.markdown deleted
100644 → 0
1 | -# archy | |
2 | - | |
3 | -Render nested hierarchies `npm ls` style with unicode pipes. | |
4 | - | |
5 | -[![browser support](http://ci.testling.com/substack/node-archy.png)](http://ci.testling.com/substack/node-archy) | |
6 | - | |
7 | -[![build status](https://secure.travis-ci.org/substack/node-archy.png)](http://travis-ci.org/substack/node-archy) | |
8 | - | |
9 | -# example | |
10 | - | |
11 | -``` js | |
12 | -var archy = require('archy'); | |
13 | -var s = archy({ | |
14 | - label : 'beep', | |
15 | - nodes : [ | |
16 | - 'ity', | |
17 | - { | |
18 | - label : 'boop', | |
19 | - nodes : [ | |
20 | - { | |
21 | - label : 'o_O', | |
22 | - nodes : [ | |
23 | - { | |
24 | - label : 'oh', | |
25 | - nodes : [ 'hello', 'puny' ] | |
26 | - }, | |
27 | - 'human' | |
28 | - ] | |
29 | - }, | |
30 | - 'party\ntime!' | |
31 | - ] | |
32 | - } | |
33 | - ] | |
34 | -}); | |
35 | -console.log(s); | |
36 | -``` | |
37 | - | |
38 | -output | |
39 | - | |
40 | -``` | |
41 | -beep | |
42 | -├── ity | |
43 | -└─┬ boop | |
44 | - ├─┬ o_O | |
45 | - │ ├─┬ oh | |
46 | - │ │ ├── hello | |
47 | - │ │ └── puny | |
48 | - │ └── human | |
49 | - └── party | |
50 | - time! | |
51 | -``` | |
52 | - | |
53 | -# methods | |
54 | - | |
55 | -var archy = require('archy') | |
56 | - | |
57 | -## archy(obj, prefix='', opts={}) | |
58 | - | |
59 | -Return a string representation of `obj` with unicode pipe characters like how | |
60 | -`npm ls` looks. | |
61 | - | |
62 | -`obj` should be a tree of nested objects with `'label'` and `'nodes'` fields. | |
63 | -`'label'` is a string of text to display at a node level and `'nodes'` is an | |
64 | -array of the descendents of the current node. | |
65 | - | |
66 | -If a node is a string, that string will be used as the `'label'` and an empty | |
67 | -array of `'nodes'` will be used. | |
68 | - | |
69 | -`prefix` gets prepended to all the lines and is used by the algorithm to | |
70 | -recursively update. | |
71 | - | |
72 | -If `'label'` has newlines they will be indented at the present indentation level | |
73 | -with the current prefix. | |
74 | - | |
75 | -To disable unicode results in favor of all-ansi output set `opts.unicode` to | |
76 | -`false`. | |
77 | - | |
78 | -# install | |
79 | - | |
80 | -With [npm](http://npmjs.org) do: | |
81 | - | |
82 | -``` | |
83 | -npm install archy | |
84 | -``` | |
85 | - | |
86 | -# license | |
87 | - | |
88 | -MIT |
images/node_modules/archy/test/beep.js deleted
100644 → 0
1 | -var test = require('tape'); | |
2 | -var archy = require('../'); | |
3 | - | |
4 | -test('beep', function (t) { | |
5 | - var s = archy({ | |
6 | - label : 'beep', | |
7 | - nodes : [ | |
8 | - 'ity', | |
9 | - { | |
10 | - label : 'boop', | |
11 | - nodes : [ | |
12 | - { | |
13 | - label : 'o_O', | |
14 | - nodes : [ | |
15 | - { | |
16 | - label : 'oh', | |
17 | - nodes : [ 'hello', 'puny' ] | |
18 | - }, | |
19 | - 'human' | |
20 | - ] | |
21 | - }, | |
22 | - 'party!' | |
23 | - ] | |
24 | - } | |
25 | - ] | |
26 | - }); | |
27 | - t.equal(s, [ | |
28 | - 'beep', | |
29 | - '├── ity', | |
30 | - '└─┬ boop', | |
31 | - ' ├─┬ o_O', | |
32 | - ' │ ├─┬ oh', | |
33 | - ' │ │ ├── hello', | |
34 | - ' │ │ └── puny', | |
35 | - ' │ └── human', | |
36 | - ' └── party!', | |
37 | - '' | |
38 | - ].join('\n')); | |
39 | - t.end(); | |
40 | -}); |
images/node_modules/archy/test/multi_line.js deleted
100644 → 0
1 | -var test = require('tape'); | |
2 | -var archy = require('../'); | |
3 | - | |
4 | -test('multi-line', function (t) { | |
5 | - var s = archy({ | |
6 | - label : 'beep\none\ntwo', | |
7 | - nodes : [ | |
8 | - 'ity', | |
9 | - { | |
10 | - label : 'boop', | |
11 | - nodes : [ | |
12 | - { | |
13 | - label : 'o_O\nwheee', | |
14 | - nodes : [ | |
15 | - { | |
16 | - label : 'oh', | |
17 | - nodes : [ 'hello', 'puny\nmeat' ] | |
18 | - }, | |
19 | - 'creature' | |
20 | - ] | |
21 | - }, | |
22 | - 'party\ntime!' | |
23 | - ] | |
24 | - } | |
25 | - ] | |
26 | - }); | |
27 | - t.equal(s, [ | |
28 | - 'beep', | |
29 | - '│ one', | |
30 | - '│ two', | |
31 | - '├── ity', | |
32 | - '└─┬ boop', | |
33 | - ' ├─┬ o_O', | |
34 | - ' │ │ wheee', | |
35 | - ' │ ├─┬ oh', | |
36 | - ' │ │ ├── hello', | |
37 | - ' │ │ └── puny', | |
38 | - ' │ │ meat', | |
39 | - ' │ └── creature', | |
40 | - ' └── party', | |
41 | - ' time!', | |
42 | - '' | |
43 | - ].join('\n')); | |
44 | - t.end(); | |
45 | -}); |
images/node_modules/archy/test/non_unicode.js deleted
100644 → 0
1 | -var test = require('tape'); | |
2 | -var archy = require('../'); | |
3 | - | |
4 | -test('beep', function (t) { | |
5 | - var s = archy({ | |
6 | - label : 'beep', | |
7 | - nodes : [ | |
8 | - 'ity', | |
9 | - { | |
10 | - label : 'boop', | |
11 | - nodes : [ | |
12 | - { | |
13 | - label : 'o_O', | |
14 | - nodes : [ | |
15 | - { | |
16 | - label : 'oh', | |
17 | - nodes : [ 'hello', 'puny' ] | |
18 | - }, | |
19 | - 'human' | |
20 | - ] | |
21 | - }, | |
22 | - 'party!' | |
23 | - ] | |
24 | - } | |
25 | - ] | |
26 | - }, '', { unicode : false }); | |
27 | - t.equal(s, [ | |
28 | - 'beep', | |
29 | - '+-- ity', | |
30 | - '`-- boop', | |
31 | - ' +-- o_O', | |
32 | - ' | +-- oh', | |
33 | - ' | | +-- hello', | |
34 | - ' | | `-- puny', | |
35 | - ' | `-- human', | |
36 | - ' `-- party!', | |
37 | - '' | |
38 | - ].join('\n')); | |
39 | - t.end(); | |
40 | -}); |
images/node_modules/argparse/HISTORY.md deleted
100644 → 0
1 | -0.1.16 / 2013-12-01 | |
2 | -------------------- | |
3 | - | |
4 | -* Maintenance release. Updated dependencies and docs. | |
5 | - | |
6 | - | |
7 | -0.1.15 / 2013-05-13 | |
8 | -------------------- | |
9 | - | |
10 | -* Fixed #55, @trebor89 | |
11 | - | |
12 | - | |
13 | -0.1.14 / 2013-05-12 | |
14 | -------------------- | |
15 | - | |
16 | -* Fixed #62, @maxtaco | |
17 | - | |
18 | - | |
19 | -0.1.13 / 2013-04-08 | |
20 | -------------------- | |
21 | - | |
22 | -* Added `.npmignore` to reduce package size | |
23 | - | |
24 | - | |
25 | -0.1.12 / 2013-02-10 | |
26 | -------------------- | |
27 | - | |
28 | -* Fixed conflictHandler (#46), @hpaulj | |
29 | - | |
30 | - | |
31 | -0.1.11 / 2013-02-07 | |
32 | -------------------- | |
33 | - | |
34 | -* Multiple bugfixes, @hpaulj | |
35 | -* Added 70+ tests (ported from python), @hpaulj | |
36 | -* Added conflictHandler, @applepicke | |
37 | -* Added fromfilePrefixChar, @hpaulj | |
38 | - | |
39 | - | |
40 | -0.1.10 / 2012-12-30 | |
41 | -------------------- | |
42 | - | |
43 | -* Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion) | |
44 | - support, thanks to @hpaulj | |
45 | -* Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj | |
46 | - | |
47 | - | |
48 | -0.1.9 / 2012-12-27 | |
49 | ------------------- | |
50 | - | |
51 | -* Fixed option dest interferens with other options (issue #23), thanks to @hpaulj | |
52 | -* Fixed default value behavior with `*` positionals, thanks to @hpaulj | |
53 | -* Improve `getDefault()` behavior, thanks to @hpaulj | |
54 | -* Imrove negative argument parsing, thanks to @hpaulj | |
55 | - | |
56 | - | |
57 | -0.1.8 / 2012-12-01 | |
58 | ------------------- | |
59 | - | |
60 | -* Fixed parser parents (issue #19), thanks to @hpaulj | |
61 | -* Fixed negative argument parse (issue #20), thanks to @hpaulj | |
62 | - | |
63 | - | |
64 | -0.1.7 / 2012-10-14 | |
65 | ------------------- | |
66 | - | |
67 | -* Fixed 'choices' argument parse (issue #16) | |
68 | -* Fixed stderr output (issue #15) | |
69 | - | |
70 | - | |
71 | -0.1.6 / 2012-09-09 | |
72 | ------------------- | |
73 | - | |
74 | -* Fixed check for conflict of options (thanks to @tomxtobin) | |
75 | - | |
76 | - | |
77 | -0.1.5 / 2012-09-03 | |
78 | ------------------- | |
79 | - | |
80 | -* Fix parser #setDefaults method (thanks to @tomxtobin) | |
81 | - | |
82 | - | |
83 | -0.1.4 / 2012-07-30 | |
84 | ------------------- | |
85 | - | |
86 | -* Fixed pseudo-argument support (thanks to @CGamesPlay) | |
87 | -* Fixed addHelp default (should be true), if not set (thanks to @benblank) | |
88 | - | |
89 | - | |
90 | -0.1.3 / 2012-06-27 | |
91 | ------------------- | |
92 | - | |
93 | -* Fixed formatter api name: Formatter -> HelpFormatter | |
94 | - | |
95 | - | |
96 | -0.1.2 / 2012-05-29 | |
97 | ------------------- | |
98 | - | |
99 | -* Added basic tests | |
100 | -* Removed excess whitespace in help | |
101 | -* Fixed error reporting, when parcer with subcommands | |
102 | - called with empty arguments | |
103 | - | |
104 | - | |
105 | -0.1.1 / 2012-05-23 | |
106 | ------------------- | |
107 | - | |
108 | -* Fixed line wrapping in help formatter | |
109 | -* Added better error reporting on invalid arguments | |
110 | - | |
111 | - | |
112 | -0.1.0 / 2012-05-16 | |
113 | ------------------- | |
114 | - | |
115 | -* First release. |
images/node_modules/argparse/LICENSE deleted
100644 → 0
1 | -(The MIT License) | |
2 | - | |
3 | -Copyright (C) 2012 by Vitaly Puzrin | |
4 | - | |
5 | -Permission is hereby granted, free of charge, to any person obtaining a copy | |
6 | -of this software and associated documentation files (the "Software"), to deal | |
7 | -in the Software without restriction, including without limitation the rights | |
8 | -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
9 | -copies of the Software, and to permit persons to whom the Software is | |
10 | -furnished to do so, subject to the following conditions: | |
11 | - | |
12 | -The above copyright notice and this permission notice shall be included in | |
13 | -all copies or substantial portions of the Software. | |
14 | - | |
15 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
18 | -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 | -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
21 | -THE SOFTWARE. |
images/node_modules/argparse/README.md deleted
100644 → 0
1 | -argparse | |
2 | -======== | |
3 | - | |
4 | -[![Build Status](https://secure.travis-ci.org/nodeca/argparse.png?branch=master)](http://travis-ci.org/nodeca/argparse) | |
5 | - | |
6 | -CLI arguments parser for node.js. Javascript port of python's | |
7 | -[argparse](http://docs.python.org/dev/library/argparse.html) module | |
8 | -(original version 3.2). That's a full port, except some very rare options, | |
9 | -recorded in issue tracker. | |
10 | - | |
11 | -**NB.** Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/). | |
12 | - | |
13 | - | |
14 | -Example | |
15 | -======= | |
16 | - | |
17 | -test.js file: | |
18 | - | |
19 | -```javascript | |
20 | -#!/usr/bin/env node | |
21 | -'use strict'; | |
22 | - | |
23 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
24 | -var parser = new ArgumentParser({ | |
25 | - version: '0.0.1', | |
26 | - addHelp:true, | |
27 | - description: 'Argparse example' | |
28 | -}); | |
29 | -parser.addArgument( | |
30 | - [ '-f', '--foo' ], | |
31 | - { | |
32 | - help: 'foo bar' | |
33 | - } | |
34 | -); | |
35 | -parser.addArgument( | |
36 | - [ '-b', '--bar' ], | |
37 | - { | |
38 | - help: 'bar foo' | |
39 | - } | |
40 | -); | |
41 | -var args = parser.parseArgs(); | |
42 | -console.dir(args); | |
43 | -``` | |
44 | - | |
45 | -Display help: | |
46 | - | |
47 | -``` | |
48 | -$ ./test.js -h | |
49 | -usage: example.js [-h] [-v] [-f FOO] [-b BAR] | |
50 | - | |
51 | -Argparse example | |
52 | - | |
53 | -Optional arguments: | |
54 | - -h, --help Show this help message and exit. | |
55 | - -v, --version Show program's version number and exit. | |
56 | - -f FOO, --foo FOO foo bar | |
57 | - -b BAR, --bar BAR bar foo | |
58 | -``` | |
59 | - | |
60 | -Parse arguments: | |
61 | - | |
62 | -``` | |
63 | -$ ./test.js -f=3 --bar=4 | |
64 | -{ foo: '3', bar: '4' } | |
65 | -``` | |
66 | - | |
67 | -More [examples](https://github.com/nodeca/argparse/tree/master/examples). | |
68 | - | |
69 | - | |
70 | -ArgumentParser objects | |
71 | -====================== | |
72 | - | |
73 | -``` | |
74 | -new ArgumentParser({paramters hash}); | |
75 | -``` | |
76 | - | |
77 | -Creates a new ArgumentParser object. | |
78 | - | |
79 | -**Supported params:** | |
80 | - | |
81 | -- ```description``` - Text to display before the argument help. | |
82 | -- ```epilog``` - Text to display after the argument help. | |
83 | -- ```addHelp``` - Add a -h/–help option to the parser. (default: true) | |
84 | -- ```argumentDefault``` - Set the global default value for arguments. (default: null) | |
85 | -- ```parents``` - A list of ArgumentParser objects whose arguments should also be included. | |
86 | -- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘) | |
87 | -- ```formatterClass``` - A class for customizing the help output. | |
88 | -- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`) | |
89 | -- ```usage``` - The string describing the program usage (default: generated) | |
90 | -- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals. | |
91 | - | |
92 | -**Not supportied yet** | |
93 | - | |
94 | -- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read. | |
95 | - | |
96 | - | |
97 | -Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects) | |
98 | - | |
99 | - | |
100 | -addArgument() method | |
101 | -==================== | |
102 | - | |
103 | -``` | |
104 | -ArgumentParser.addArgument([names or flags], {options}) | |
105 | -``` | |
106 | - | |
107 | -Defines how a single command-line argument should be parsed. | |
108 | - | |
109 | -- ```name or flags``` - Either a name or a list of option strings, e.g. foo or -f, --foo. | |
110 | - | |
111 | -Options: | |
112 | - | |
113 | -- ```action``` - The basic type of action to be taken when this argument is encountered at the command line. | |
114 | -- ```nargs```- The number of command-line arguments that should be consumed. | |
115 | -- ```constant``` - A constant value required by some action and nargs selections. | |
116 | -- ```defaultValue``` - The value produced if the argument is absent from the command line. | |
117 | -- ```type``` - The type to which the command-line argument should be converted. | |
118 | -- ```choices``` - A container of the allowable values for the argument. | |
119 | -- ```required``` - Whether or not the command-line option may be omitted (optionals only). | |
120 | -- ```help``` - A brief description of what the argument does. | |
121 | -- ```metavar``` - A name for the argument in usage messages. | |
122 | -- ```dest``` - The name of the attribute to be added to the object returned by parseArgs(). | |
123 | - | |
124 | -Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method) | |
125 | - | |
126 | - | |
127 | -Action (some details) | |
128 | -================ | |
129 | - | |
130 | -ArgumentParser objects associate command-line arguments with actions. | |
131 | -These actions can do just about anything with the command-line arguments associated | |
132 | -with them, though most actions simply add an attribute to the object returned by | |
133 | -parseArgs(). The action keyword argument specifies how the command-line arguments | |
134 | -should be handled. The supported actions are: | |
135 | - | |
136 | -- ```store``` - Just stores the argument’s value. This is the default action. | |
137 | -- ```storeConst``` - Stores value, specified by the const keyword argument. | |
138 | - (Note that the const keyword argument defaults to the rather unhelpful None.) | |
139 | - The 'storeConst' action is most commonly used with optional arguments, that | |
140 | - specify some sort of flag. | |
141 | -- ```storeTrue``` and ```storeFalse``` - Stores values True and False | |
142 | - respectively. These are special cases of 'storeConst'. | |
143 | -- ```append``` - Stores a list, and appends each argument value to the list. | |
144 | - This is useful to allow an option to be specified multiple times. | |
145 | -- ```appendConst``` - Stores a list, and appends value, specified by the | |
146 | - const keyword argument to the list. (Note, that the const keyword argument defaults | |
147 | - is None.) The 'appendConst' action is typically used when multiple arguments need | |
148 | - to store constants to the same list. | |
149 | -- ```count``` - Counts the number of times a keyword argument occurs. For example, | |
150 | - used for increasing verbosity levels. | |
151 | -- ```help``` - Prints a complete help message for all the options in the current | |
152 | - parser and then exits. By default a help action is automatically added to the parser. | |
153 | - See ArgumentParser for details of how the output is created. | |
154 | -- ```version``` - Prints version information and exit. Expects a `version=` | |
155 | - keyword argument in the addArgument() call. | |
156 | - | |
157 | -Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action) | |
158 | - | |
159 | - | |
160 | -Sub-commands | |
161 | -============ | |
162 | - | |
163 | -ArgumentParser.addSubparsers() | |
164 | - | |
165 | -Many programs split their functionality into a number of sub-commands, for | |
166 | -example, the svn program can invoke sub-commands like `svn checkout`, `svn update`, | |
167 | -and `svn commit`. Splitting up functionality this way can be a particularly good | |
168 | -idea when a program performs several different functions which require different | |
169 | -kinds of command-line arguments. `ArgumentParser` supports creation of such | |
170 | -sub-commands with `addSubparsers()` method. The `addSubparsers()` method is | |
171 | -normally called with no arguments and returns an special action object. | |
172 | -This object has a single method `addParser()`, which takes a command name and | |
173 | -any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object | |
174 | -that can be modified as usual. | |
175 | - | |
176 | -Example: | |
177 | - | |
178 | -sub_commands.js | |
179 | -```javascript | |
180 | -#!/usr/bin/env node | |
181 | -'use strict'; | |
182 | - | |
183 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
184 | -var parser = new ArgumentParser({ | |
185 | - version: '0.0.1', | |
186 | - addHelp:true, | |
187 | - description: 'Argparse examples: sub-commands', | |
188 | -}); | |
189 | - | |
190 | -var subparsers = parser.addSubparsers({ | |
191 | - title:'subcommands', | |
192 | - dest:"subcommand_name" | |
193 | -}); | |
194 | - | |
195 | -var bar = subparsers.addParser('c1', {addHelp:true}); | |
196 | -bar.addArgument( | |
197 | - [ '-f', '--foo' ], | |
198 | - { | |
199 | - action: 'store', | |
200 | - help: 'foo3 bar3' | |
201 | - } | |
202 | -); | |
203 | -var bar = subparsers.addParser( | |
204 | - 'c2', | |
205 | - {aliases:['co'], addHelp:true} | |
206 | -); | |
207 | -bar.addArgument( | |
208 | - [ '-b', '--bar' ], | |
209 | - { | |
210 | - action: 'store', | |
211 | - type: 'int', | |
212 | - help: 'foo3 bar3' | |
213 | - } | |
214 | -); | |
215 | - | |
216 | -var args = parser.parseArgs(); | |
217 | -console.dir(args); | |
218 | - | |
219 | -``` | |
220 | - | |
221 | -Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands) | |
222 | - | |
223 | - | |
224 | -Contributors | |
225 | -============ | |
226 | - | |
227 | -- [Eugene Shkuropat](https://github.com/shkuropat) | |
228 | -- [Paul Jacobson](https://github.com/hpaulj) | |
229 | - | |
230 | -[others](https://github.com/nodeca/argparse/graphs/contributors) | |
231 | - | |
232 | -License | |
233 | -======= | |
234 | - | |
235 | -Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin). | |
236 | -Released under the MIT license. See | |
237 | -[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details. | |
238 | - | |
239 | - |
images/node_modules/argparse/examples/arguments.js deleted
100755 → 0
1 | -#!/usr/bin/env node | |
2 | -'use strict'; | |
3 | - | |
4 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
5 | -var parser = new ArgumentParser({ | |
6 | - version: '0.0.1', | |
7 | - addHelp: true, | |
8 | - description: 'Argparse examples: arguments' | |
9 | -}); | |
10 | -parser.addArgument( | |
11 | - [ '-f', '--foo' ], | |
12 | - { | |
13 | - help: 'foo bar' | |
14 | - } | |
15 | -); | |
16 | -parser.addArgument( | |
17 | - [ '-b', '--bar' ], | |
18 | - { | |
19 | - help: 'bar foo' | |
20 | - } | |
21 | -); | |
22 | - | |
23 | - | |
24 | -parser.printHelp(); | |
25 | -console.log('-----------'); | |
26 | - | |
27 | -var args; | |
28 | -args = parser.parseArgs('-f 1 -b2'.split(' ')); | |
29 | -console.dir(args); | |
30 | -console.log('-----------'); | |
31 | -args = parser.parseArgs('-f=3 --bar=4'.split(' ')); | |
32 | -console.dir(args); | |
33 | -console.log('-----------'); | |
34 | -args = parser.parseArgs('--foo 5 --bar 6'.split(' ')); | |
35 | -console.dir(args); | |
36 | -console.log('-----------'); |
images/node_modules/argparse/examples/choice.js deleted
100755 → 0
1 | -#!/usr/bin/env node | |
2 | -'use strict'; | |
3 | - | |
4 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
5 | -var parser = new ArgumentParser({ | |
6 | - version: '0.0.1', | |
7 | - addHelp: true, | |
8 | - description: 'Argparse examples: choice' | |
9 | -}); | |
10 | - | |
11 | -parser.addArgument(['foo'], {choices: 'abc'}); | |
12 | - | |
13 | -parser.printHelp(); | |
14 | -console.log('-----------'); | |
15 | - | |
16 | -var args; | |
17 | -args = parser.parseArgs(['c']); | |
18 | -console.dir(args); | |
19 | -console.log('-----------'); | |
20 | -parser.parseArgs(['X']); | |
21 | -console.dir(args); | |
22 | - |
images/node_modules/argparse/examples/constants.js deleted
100755 → 0
1 | -#!/usr/bin/env node | |
2 | -'use strict'; | |
3 | - | |
4 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
5 | -var parser = new ArgumentParser({ | |
6 | - version: '0.0.1', | |
7 | - addHelp: true, | |
8 | - description: 'Argparse examples: constant' | |
9 | -}); | |
10 | - | |
11 | -parser.addArgument( | |
12 | - [ '-a'], | |
13 | - { | |
14 | - action: 'storeConst', | |
15 | - dest: 'answer', | |
16 | - help: 'store constant', | |
17 | - constant: 42 | |
18 | - } | |
19 | -); | |
20 | -parser.addArgument( | |
21 | - [ '--str' ], | |
22 | - { | |
23 | - action: 'appendConst', | |
24 | - dest: 'types', | |
25 | - help: 'append constant "str" to types', | |
26 | - constant: 'str' | |
27 | - } | |
28 | -); | |
29 | -parser.addArgument( | |
30 | - [ '--int' ], | |
31 | - { | |
32 | - action: 'appendConst', | |
33 | - dest: 'types', | |
34 | - help: 'append constant "int" to types', | |
35 | - constant: 'int' | |
36 | - } | |
37 | -); | |
38 | - | |
39 | -parser.addArgument( | |
40 | - [ '--true' ], | |
41 | - { | |
42 | - action: 'storeTrue', | |
43 | - help: 'store true constant' | |
44 | - } | |
45 | -); | |
46 | -parser.addArgument( | |
47 | - [ '--false' ], | |
48 | - { | |
49 | - action: 'storeFalse', | |
50 | - help: 'store false constant' | |
51 | - } | |
52 | -); | |
53 | - | |
54 | -parser.printHelp(); | |
55 | -console.log('-----------'); | |
56 | - | |
57 | -var args; | |
58 | -args = parser.parseArgs('-a --str --int --true'.split(' ')); | |
59 | -console.dir(args); |
images/node_modules/argparse/examples/help.js deleted
100755 → 0
1 | -#!/usr/bin/env node | |
2 | -'use strict'; | |
3 | - | |
4 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
5 | -var parser = new ArgumentParser({ | |
6 | - version: '0.0.1', | |
7 | - addHelp: true, | |
8 | - description: 'Argparse examples: help', | |
9 | - epilog: 'help epilog', | |
10 | - prog: 'help_example_prog', | |
11 | - usage: 'Usage %(prog)s <agrs>' | |
12 | -}); | |
13 | -parser.printHelp(); |
images/node_modules/argparse/examples/nargs.js deleted
100755 → 0
1 | -#!/usr/bin/env node | |
2 | -'use strict'; | |
3 | - | |
4 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
5 | -var parser = new ArgumentParser({ | |
6 | - version: '0.0.1', | |
7 | - addHelp: true, | |
8 | - description: 'Argparse examples: nargs' | |
9 | -}); | |
10 | -parser.addArgument( | |
11 | - [ '-f', '--foo' ], | |
12 | - { | |
13 | - help: 'foo bar', | |
14 | - nargs: 1 | |
15 | - } | |
16 | -); | |
17 | -parser.addArgument( | |
18 | - [ '-b', '--bar' ], | |
19 | - { | |
20 | - help: 'bar foo', | |
21 | - nargs: '*' | |
22 | - } | |
23 | -); | |
24 | - | |
25 | -parser.printHelp(); | |
26 | -console.log('-----------'); | |
27 | - | |
28 | -var args; | |
29 | -args = parser.parseArgs('--foo a --bar c d'.split(' ')); | |
30 | -console.dir(args); | |
31 | -console.log('-----------'); | |
32 | -args = parser.parseArgs('--bar b c f --foo a'.split(' ')); | |
33 | -console.dir(args); |
images/node_modules/argparse/examples/parents.js deleted
100755 → 0
1 | -#!/usr/bin/env node | |
2 | -'use strict'; | |
3 | - | |
4 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
5 | - | |
6 | -var args; | |
7 | -var parent_parser = new ArgumentParser({ addHelp: false }); | |
8 | -// note addHelp:false to prevent duplication of the -h option | |
9 | -parent_parser.addArgument( | |
10 | - ['--parent'], | |
11 | - { type: 'int', description: 'parent' } | |
12 | -); | |
13 | - | |
14 | -var foo_parser = new ArgumentParser({ | |
15 | - parents: [ parent_parser ], | |
16 | - description: 'child1' | |
17 | -}); | |
18 | -foo_parser.addArgument(['foo']); | |
19 | -args = foo_parser.parseArgs(['--parent', '2', 'XXX']); | |
20 | -console.log(args); | |
21 | - | |
22 | -var bar_parser = new ArgumentParser({ | |
23 | - parents: [ parent_parser ], | |
24 | - description: 'child2' | |
25 | -}); | |
26 | -bar_parser.addArgument(['--bar']); | |
27 | -args = bar_parser.parseArgs(['--bar', 'YYY']); | |
28 | -console.log(args); |
images/node_modules/argparse/examples/prefix_chars.js deleted
100755 → 0
1 | -#!/usr/bin/env node | |
2 | -'use strict'; | |
3 | - | |
4 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
5 | -var parser = new ArgumentParser({ | |
6 | - version: '0.0.1', | |
7 | - addHelp: true, | |
8 | - description: 'Argparse examples: prefix_chars', | |
9 | - prefixChars: '-+' | |
10 | -}); | |
11 | -parser.addArgument(['+f', '++foo']); | |
12 | -parser.addArgument(['++bar'], {action: 'storeTrue'}); | |
13 | - | |
14 | -parser.printHelp(); | |
15 | -console.log('-----------'); | |
16 | - | |
17 | -var args; | |
18 | -args = parser.parseArgs(['+f', '1']); | |
19 | -console.dir(args); | |
20 | -args = parser.parseArgs(['++bar']); | |
21 | -console.dir(args); | |
22 | -args = parser.parseArgs(['++foo', '2', '++bar']); | |
23 | -console.dir(args); |
images/node_modules/argparse/examples/sub_commands.js deleted
100755 → 0
1 | -#!/usr/bin/env node | |
2 | -'use strict'; | |
3 | - | |
4 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
5 | -var parser = new ArgumentParser({ | |
6 | - version: '0.0.1', | |
7 | - addHelp: true, | |
8 | - description: 'Argparse examples: sub-commands' | |
9 | -}); | |
10 | - | |
11 | -var subparsers = parser.addSubparsers({ | |
12 | - title: 'subcommands', | |
13 | - dest: "subcommand_name" | |
14 | -}); | |
15 | - | |
16 | -var bar = subparsers.addParser('c1', {addHelp: true, help: 'c1 help'}); | |
17 | -bar.addArgument( | |
18 | - [ '-f', '--foo' ], | |
19 | - { | |
20 | - action: 'store', | |
21 | - help: 'foo3 bar3' | |
22 | - } | |
23 | -); | |
24 | -var bar = subparsers.addParser( | |
25 | - 'c2', | |
26 | - {aliases: ['co'], addHelp: true, help: 'c2 help'} | |
27 | -); | |
28 | -bar.addArgument( | |
29 | - [ '-b', '--bar' ], | |
30 | - { | |
31 | - action: 'store', | |
32 | - type: 'int', | |
33 | - help: 'foo3 bar3' | |
34 | - } | |
35 | -); | |
36 | -parser.printHelp(); | |
37 | -console.log('-----------'); | |
38 | - | |
39 | -var args; | |
40 | -args = parser.parseArgs('c1 -f 2'.split(' ')); | |
41 | -console.dir(args); | |
42 | -console.log('-----------'); | |
43 | -args = parser.parseArgs('c2 -b 1'.split(' ')); | |
44 | -console.dir(args); | |
45 | -console.log('-----------'); | |
46 | -args = parser.parseArgs('co -b 1'.split(' ')); | |
47 | -console.dir(args); | |
48 | -console.log('-----------'); | |
49 | -parser.parseArgs(['c1', '-h']); |
images/node_modules/argparse/examples/sum.js deleted
100755 → 0
1 | -#!/usr/bin/env node | |
2 | - | |
3 | -'use strict'; | |
4 | - | |
5 | - | |
6 | -var ArgumentParser = require('../lib/argparse').ArgumentParser; | |
7 | -var parser = new ArgumentParser({ description: 'Process some integers.' }); | |
8 | - | |
9 | - | |
10 | -function sum(arr) { | |
11 | - return arr.reduce(function (a, b) { | |
12 | - return a + b; | |
13 | - }, 0); | |
14 | -} | |
15 | -function max(arr) { | |
16 | - return Math.max.apply(Math, arr); | |
17 | -} | |
18 | - | |
19 | - | |
20 | -parser.addArgument(['integers'], { | |
21 | - metavar: 'N', | |
22 | - type: 'int', | |
23 | - nargs: '+', | |
24 | - help: 'an integer for the accumulator' | |
25 | -}); | |
26 | -parser.addArgument(['--sum'], { | |
27 | - dest: 'accumulate', | |
28 | - action: 'storeConst', | |
29 | - constant: sum, | |
30 | - defaultValue: max, | |
31 | - help: 'sum the integers (default: find the max)' | |
32 | -}); | |
33 | - | |
34 | -var args = parser.parseArgs('--sum 1 2 -1'.split(' ')); | |
35 | -console.log(args.accumulate(args.integers)); |
images/node_modules/argparse/examples/testformatters.js deleted
100644 → 0
1 | -'use strict'; | |
2 | - | |
3 | -var a, group, parser, helptext; | |
4 | - | |
5 | -var assert = require('assert'); | |
6 | -var _ = require('underscore'); | |
7 | -_.str = require('underscore.string'); | |
8 | -var print = function () { | |
9 | - return console.log.apply(console, arguments); | |
10 | - }; | |
11 | -// print = function () {}; | |
12 | - | |
13 | -var argparse = require('argparse'); | |
14 | - | |
15 | -print("TEST argparse.ArgumentDefaultsHelpFormatter"); | |
16 | - | |
17 | -parser = new argparse.ArgumentParser({ | |
18 | - debug: true, | |
19 | - formatterClass: argparse.ArgumentDefaultsHelpFormatter, | |
20 | - description: 'description' | |
21 | -}); | |
22 | - | |
23 | -parser.addArgument(['--foo'], { | |
24 | - help: 'foo help - oh and by the way, %(defaultValue)s' | |
25 | -}); | |
26 | - | |
27 | -parser.addArgument(['--bar'], { | |
28 | - action: 'storeTrue', | |
29 | - help: 'bar help' | |
30 | -}); | |
31 | - | |
32 | -parser.addArgument(['spam'], { | |
33 | - help: 'spam help' | |
34 | -}); | |
35 | - | |
36 | -parser.addArgument(['badger'], { | |
37 | - nargs: '?', | |
38 | - defaultValue: 'wooden', | |
39 | - help: 'badger help' | |
40 | -}); | |
41 | - | |
42 | -group = parser.addArgumentGroup({ | |
43 | - title: 'title', | |
44 | - description: 'group description' | |
45 | -}); | |
46 | - | |
47 | -group.addArgument(['--baz'], { | |
48 | - type: 'int', | |
49 | - defaultValue: 42, | |
50 | - help: 'baz help' | |
51 | -}); | |
52 | - | |
53 | -helptext = parser.formatHelp(); | |
54 | -print(helptext); | |
55 | -// test selected clips | |
56 | -assert(helptext.match(/badger help \(default: wooden\)/)); | |
57 | -assert(helptext.match(/foo help - oh and by the way, null/)); | |
58 | -assert(helptext.match(/bar help \(default: false\)/)); | |
59 | -assert(helptext.match(/title:\n {2}group description/)); // test indent | |
60 | -assert(helptext.match(/baz help \(default: 42\)/im)); | |
61 | - | |
62 | -/* | |
63 | -usage: PROG [-h] [--foo FOO] [--bar] [--baz BAZ] spam [badger] | |
64 | - | |
65 | -description | |
66 | - | |
67 | -positional arguments: | |
68 | - spam spam help | |
69 | - badger badger help (default: wooden) | |
70 | - | |
71 | -optional arguments: | |
72 | - -h, --help show this help message and exit | |
73 | - --foo FOO foo help - oh and by the way, null | |
74 | - --bar bar help (default: false) | |
75 | - | |
76 | -title: | |
77 | - group description | |
78 | - | |
79 | - --baz BAZ baz help (default: 42) | |
80 | -*/ | |
81 | - | |
82 | -print("TEST argparse.RawDescriptionHelpFormatter"); | |
83 | - | |
84 | -parser = new argparse.ArgumentParser({ | |
85 | - debug: true, | |
86 | - prog: 'PROG', | |
87 | - formatterClass: argparse.RawDescriptionHelpFormatter, | |
88 | - description: 'Keep the formatting\n' + | |
89 | - ' exactly as it is written\n' + | |
90 | - '\n' + | |
91 | - 'here\n' | |
92 | -}); | |
93 | - | |
94 | -a = parser.addArgument(['--foo'], { | |
95 | - help: ' foo help should not\n' + | |
96 | - ' retain this odd formatting' | |
97 | -}); | |
98 | - | |
99 | -parser.addArgument(['spam'], { | |
100 | - 'help': 'spam help' | |
101 | -}); | |
102 | - | |
103 | -group = parser.addArgumentGroup({ | |
104 | - title: 'title', | |
105 | - description: ' This text\n' + | |
106 | - ' should be indented\n' + | |
107 | - ' exactly like it is here\n' | |
108 | -}); | |
109 | - | |
110 | -group.addArgument(['--bar'], { | |
111 | - help: 'bar help' | |
112 | -}); | |
113 | - | |
114 | -helptext = parser.formatHelp(); | |
115 | -print(helptext); | |
116 | -// test selected clips | |
117 | -assert(helptext.match(parser.description)); | |
118 | -assert.equal(helptext.match(a.help), null); | |
119 | -assert(helptext.match(/foo help should not retain this odd formatting/)); | |
120 | - | |
121 | -/* | |
122 | -class TestHelpRawDescription(HelpTestCase): | |
123 | - """Test the RawTextHelpFormatter""" | |
124 | -.... | |
125 | - | |
126 | -usage: PROG [-h] [--foo FOO] [--bar BAR] spam | |
127 | - | |
128 | -Keep the formatting | |
129 | - exactly as it is written | |
130 | - | |
131 | -here | |
132 | - | |
133 | -positional arguments: | |
134 | - spam spam help | |
135 | - | |
136 | -optional arguments: | |
137 | - -h, --help show this help message and exit | |
138 | - --foo FOO foo help should not retain this odd formatting | |
139 | - | |
140 | -title: | |
141 | - This text | |
142 | - should be indented | |
143 | - exactly like it is here | |
144 | - | |
145 | - --bar BAR bar help | |
146 | -*/ | |
147 | - | |
148 | - | |
149 | -print("TEST argparse.RawTextHelpFormatter"); | |
150 | - | |
151 | -parser = new argparse.ArgumentParser({ | |
152 | - debug: true, | |
153 | - prog: 'PROG', | |
154 | - formatterClass: argparse.RawTextHelpFormatter, | |
155 | - description: 'Keep the formatting\n' + | |
156 | - ' exactly as it is written\n' + | |
157 | - '\n' + | |
158 | - 'here\n' | |
159 | -}); | |
160 | - | |
161 | -parser.addArgument(['--baz'], { | |
162 | - help: ' baz help should also\n' + | |
163 | - 'appear as given here' | |
164 | -}); | |
165 | - | |
166 | -a = parser.addArgument(['--foo'], { | |
167 | - help: ' foo help should also\n' + | |
168 | - 'appear as given here' | |
169 | -}); | |
170 | - | |
171 | -parser.addArgument(['spam'], { | |
172 | - 'help': 'spam help' | |
173 | -}); | |
174 | - | |
175 | -group = parser.addArgumentGroup({ | |
176 | - title: 'title', | |
177 | - description: ' This text\n' + | |
178 | - ' should be indented\n' + | |
179 | - ' exactly like it is here\n' | |
180 | -}); | |
181 | - | |
182 | -group.addArgument(['--bar'], { | |
183 | - help: 'bar help' | |
184 | -}); | |
185 | - | |
186 | -helptext = parser.formatHelp(); | |
187 | -print(helptext); | |
188 | -// test selected clips | |
189 | -assert(helptext.match(parser.description)); | |
190 | -assert(helptext.match(/( {14})appear as given here/gm)); | |
191 | - | |
192 | -/* | |
193 | -class TestHelpRawText(HelpTestCase): | |
194 | - """Test the RawTextHelpFormatter""" | |
195 | - | |
196 | -usage: PROG [-h] [--foo FOO] [--bar BAR] spam | |
197 | - | |
198 | -Keep the formatting | |
199 | - exactly as it is written | |
200 | - | |
201 | -here | |
202 | - | |
203 | -positional arguments: | |
204 | - spam spam help | |
205 | - | |
206 | -optional arguments: | |
207 | - -h, --help show this help message and exit | |
208 | - --foo FOO foo help should also | |
209 | - appear as given here | |
210 | - | |
211 | -title: | |
212 | - This text | |
213 | - should be indented | |
214 | - exactly like it is here | |
215 | - | |
216 | - --bar BAR bar help | |
217 | -*/ | |
218 | - | |
219 | - | |
220 | -print("TEST metavar as a tuple"); | |
221 | - | |
222 | -parser = new argparse.ArgumentParser({ | |
223 | - prog: 'PROG' | |
224 | -}); | |
225 | - | |
226 | -parser.addArgument(['-w'], { | |
227 | - help: 'w', | |
228 | - nargs: '+', | |
229 | - metavar: ['W1', 'W2'] | |
230 | -}); | |
231 | - | |
232 | -parser.addArgument(['-x'], { | |
233 | - help: 'x', | |
234 | - nargs: '*', | |
235 | - metavar: ['X1', 'X2'] | |
236 | -}); | |
237 | - | |
238 | -parser.addArgument(['-y'], { | |
239 | - help: 'y', | |
240 | - nargs: 3, | |
241 | - metavar: ['Y1', 'Y2', 'Y3'] | |
242 | -}); | |
243 | - | |
244 | -parser.addArgument(['-z'], { | |
245 | - help: 'z', | |
246 | - nargs: '?', | |
247 | - metavar: ['Z1'] | |
248 | -}); | |
249 | - | |
250 | -helptext = parser.formatHelp(); | |
251 | -print(helptext); | |
252 | -var ustring = 'PROG [-h] [-w W1 [W2 ...]] [-x [X1 [X2 ...]]] [-y Y1 Y2 Y3] [-z [Z1]]'; | |
253 | -ustring = ustring.replace(/\[/g, '\\[').replace(/\]/g, '\\]'); | |
254 | -// print(ustring) | |
255 | -assert(helptext.match(new RegExp(ustring))); | |
256 | - | |
257 | -/* | |
258 | -class TestHelpTupleMetavar(HelpTestCase): | |
259 | - """Test specifying metavar as a tuple""" | |
260 | - | |
261 | -usage: PROG [-h] [-w W1 [W2 ...]] [-x [X1 [X2 ...]]] [-y Y1 Y2 Y3] [-z [Z1]] | |
262 | - | |
263 | -optional arguments: | |
264 | - -h, --help show this help message and exit | |
265 | - -w W1 [W2 ...] w | |
266 | - -x [X1 [X2 ...]] x | |
267 | - -y Y1 Y2 Y3 y | |
268 | - -z [Z1] z | |
269 | -*/ | |
270 | - |
images/node_modules/argparse/index.js deleted
100644 → 0
1 | -module.exports = require('./lib/argparse'); |
images/node_modules/argparse/lib/action.js deleted
100644 → 0
1 | -/** | |
2 | - * class Action | |
3 | - * | |
4 | - * Base class for all actions | |
5 | - * Do not call in your code, use this class only for inherits your own action | |
6 | - * | |
7 | - * Information about how to convert command line strings to Javascript objects. | |
8 | - * Action objects are used by an ArgumentParser to represent the information | |
9 | - * needed to parse a single argument from one or more strings from the command | |
10 | - * line. The keyword arguments to the Action constructor are also all attributes | |
11 | - * of Action instances. | |
12 | - * | |
13 | - * #####Alowed keywords: | |
14 | - * | |
15 | - * - `store` | |
16 | - * - `storeConstant` | |
17 | - * - `storeTrue` | |
18 | - * - `storeFalse` | |
19 | - * - `append` | |
20 | - * - `appendConstant` | |
21 | - * - `count` | |
22 | - * - `help` | |
23 | - * - `version` | |
24 | - * | |
25 | - * Information about action options see [[Action.new]] | |
26 | - * | |
27 | - * See also [original guide](http://docs.python.org/dev/library/argparse.html#action) | |
28 | - * | |
29 | - **/ | |
30 | - | |
31 | -'use strict'; | |
32 | - | |
33 | - | |
34 | -// Constants | |
35 | -var $$ = require('./const'); | |
36 | - | |
37 | - | |
38 | -/** | |
39 | - * new Action(options) | |
40 | - * | |
41 | - * Base class for all actions. Used only for inherits | |
42 | - * | |
43 | - * | |
44 | - * ##### Options: | |
45 | - * | |
46 | - * - `optionStrings` A list of command-line option strings for the action. | |
47 | - * - `dest` Attribute to hold the created object(s) | |
48 | - * - `nargs` The number of command-line arguments that should be consumed. | |
49 | - * By default, one argument will be consumed and a single value will be | |
50 | - * produced. | |
51 | - * - `constant` Default value for an action with no value. | |
52 | - * - `defaultValue` The value to be produced if the option is not specified. | |
53 | - * - `type` Cast to 'string'|'int'|'float'|'complex'|function (string). If | |
54 | - * None, 'string'. | |
55 | - * - `choices` The choices available. | |
56 | - * - `required` True if the action must always be specified at the command | |
57 | - * line. | |
58 | - * - `help` The help describing the argument. | |
59 | - * - `metavar` The name to be used for the option's argument with the help | |
60 | - * string. If None, the 'dest' value will be used as the name. | |
61 | - * | |
62 | - * ##### nargs supported values: | |
63 | - * | |
64 | - * - `N` (an integer) consumes N arguments (and produces a list) | |
65 | - * - `?` consumes zero or one arguments | |
66 | - * - `*` consumes zero or more arguments (and produces a list) | |
67 | - * - `+` consumes one or more arguments (and produces a list) | |
68 | - * | |
69 | - * Note: that the difference between the default and nargs=1 is that with the | |
70 | - * default, a single value will be produced, while with nargs=1, a list | |
71 | - * containing a single value will be produced. | |
72 | - **/ | |
73 | -var Action = module.exports = function Action(options) { | |
74 | - options = options || {}; | |
75 | - this.optionStrings = options.optionStrings || []; | |
76 | - this.dest = options.dest; | |
77 | - this.nargs = options.nargs !== undefined ? options.nargs : null; | |
78 | - this.constant = options.constant !== undefined ? options.constant : null; | |
79 | - this.defaultValue = options.defaultValue; | |
80 | - this.type = options.type !== undefined ? options.type : null; | |
81 | - this.choices = options.choices !== undefined ? options.choices : null; | |
82 | - this.required = options.required !== undefined ? options.required: false; | |
83 | - this.help = options.help !== undefined ? options.help : null; | |
84 | - this.metavar = options.metavar !== undefined ? options.metavar : null; | |
85 | - | |
86 | - if (!(this.optionStrings instanceof Array)) { | |
87 | - throw new Error('optionStrings should be an array'); | |
88 | - } | |
89 | - if (this.required !== undefined && typeof(this.required) !== 'boolean') { | |
90 | - throw new Error('required should be a boolean'); | |
91 | - } | |
92 | -}; | |
93 | - | |
94 | -/** | |
95 | - * Action#getName -> String | |
96 | - * | |
97 | - * Tells action name | |
98 | - **/ | |
99 | -Action.prototype.getName = function () { | |
100 | - if (this.optionStrings.length > 0) { | |
101 | - return this.optionStrings.join('/'); | |
102 | - } else if (this.metavar !== null && this.metavar !== $$.SUPPRESS) { | |
103 | - return this.metavar; | |
104 | - } else if (this.dest !== undefined && this.dest !== $$.SUPPRESS) { | |
105 | - return this.dest; | |
106 | - } | |
107 | - return null; | |
108 | -}; | |
109 | - | |
110 | -/** | |
111 | - * Action#isOptional -> Boolean | |
112 | - * | |
113 | - * Return true if optional | |
114 | - **/ | |
115 | -Action.prototype.isOptional = function () { | |
116 | - return !this.isPositional(); | |
117 | -}; | |
118 | - | |
119 | -/** | |
120 | - * Action#isPositional -> Boolean | |
121 | - * | |
122 | - * Return true if positional | |
123 | - **/ | |
124 | -Action.prototype.isPositional = function () { | |
125 | - return (this.optionStrings.length === 0); | |
126 | -}; | |
127 | - | |
128 | -/** | |
129 | - * Action#call(parser, namespace, values, optionString) -> Void | |
130 | - * - parser (ArgumentParser): current parser | |
131 | - * - namespace (Namespace): namespace for output data | |
132 | - * - values (Array): parsed values | |
133 | - * - optionString (Array): input option string(not parsed) | |
134 | - * | |
135 | - * Call the action. Should be implemented in inherited classes | |
136 | - * | |
137 | - * ##### Example | |
138 | - * | |
139 | - * ActionCount.prototype.call = function (parser, namespace, values, optionString) { | |
140 | - * namespace.set(this.dest, (namespace[this.dest] || 0) + 1); | |
141 | - * }; | |
142 | - * | |
143 | - **/ | |
144 | -Action.prototype.call = function () { | |
145 | - throw new Error('.call() not defined');// Not Implemented error | |
146 | -}; |
images/node_modules/argparse/lib/action/append.js deleted
100644 → 0
1 | -/*:nodoc:* | |
2 | - * class ActionAppend | |
3 | - * | |
4 | - * This action stores a list, and appends each argument value to the list. | |
5 | - * This is useful to allow an option to be specified multiple times. | |
6 | - * This class inherided from [[Action]] | |
7 | - * | |
8 | - **/ | |
9 | - | |
10 | -'use strict'; | |
11 | - | |
12 | -var util = require('util'); | |
13 | - | |
14 | -var Action = require('../action'); | |
15 | - | |
16 | -// Constants | |
17 | -var $$ = require('../const'); | |
18 | - | |
19 | -/*:nodoc:* | |
20 | - * new ActionAppend(options) | |
21 | - * - options (object): options hash see [[Action.new]] | |
22 | - * | |
23 | - * Note: options.nargs should be optional for constants | |
24 | - * and more then zero for other | |
25 | - **/ | |
26 | -var ActionAppend = module.exports = function ActionAppend(options) { | |
27 | - options = options || {}; | |
28 | - if (this.nargs <= 0) { | |
29 | - throw new Error('nargs for append actions must be > 0; if arg ' + | |
30 | - 'strings are not supplying the value to append, ' + | |
31 | - 'the append const action may be more appropriate'); | |
32 | - } | |
33 | - if (!!this.constant && this.nargs !== $$.OPTIONAL) { | |
34 | - throw new Error('nargs must be OPTIONAL to supply const'); | |
35 | - } | |
36 | - Action.call(this, options); | |
37 | -}; | |
38 | -util.inherits(ActionAppend, Action); | |
39 | - | |
40 | -/*:nodoc:* | |
41 | - * ActionAppend#call(parser, namespace, values, optionString) -> Void | |
42 | - * - parser (ArgumentParser): current parser | |
43 | - * - namespace (Namespace): namespace for output data | |
44 | - * - values (Array): parsed values | |
45 | - * - optionString (Array): input option string(not parsed) | |
46 | - * | |
47 | - * Call the action. Save result in namespace object | |
48 | - **/ | |
49 | -ActionAppend.prototype.call = function (parser, namespace, values) { | |
50 | - var items = [].concat(namespace[this.dest] || []); // or _.clone | |
51 | - items.push(values); | |
52 | - namespace.set(this.dest, items); | |
53 | -}; | |
54 | - | |
55 | - |
images/node_modules/argparse/lib/action/append/constant.js deleted
100644 → 0
1 | -/*:nodoc:* | |
2 | - * class ActionAppendConstant | |
3 | - * | |
4 | - * This stores a list, and appends the value specified by | |
5 | - * the const keyword argument to the list. | |
6 | - * (Note that the const keyword argument defaults to null.) | |
7 | - * The 'appendConst' action is typically useful when multiple | |
8 | - * arguments need to store constants to the same list. | |
9 | - * | |
10 | - * This class inherited from [[Action]] | |
11 | - **/ | |
12 | - | |
13 | -'use strict'; | |
14 | - | |
15 | -var util = require('util'); | |
16 | - | |
17 | -var Action = require('../../action'); | |
18 | - | |
19 | -/*:nodoc:* | |
20 | - * new ActionAppendConstant(options) | |
21 | - * - options (object): options hash see [[Action.new]] | |
22 | - * | |
23 | - **/ | |
24 | -var ActionAppendConstant = module.exports = function ActionAppendConstant(options) { | |
25 | - options = options || {}; | |
26 | - options.nargs = 0; | |
27 | - if (options.constant === undefined) { | |
28 | - throw new Error('constant option is required for appendAction'); | |
29 | - } | |
30 | - Action.call(this, options); | |
31 | -}; | |
32 | -util.inherits(ActionAppendConstant, Action); | |
33 | - | |
34 | -/*:nodoc:* | |
35 | - * ActionAppendConstant#call(parser, namespace, values, optionString) -> Void | |
36 | - * - parser (ArgumentParser): current parser | |
37 | - * - namespace (Namespace): namespace for output data | |
38 | - * - values (Array): parsed values | |
39 | - * - optionString (Array): input option string(not parsed) | |
40 | - * | |
41 | - * Call the action. Save result in namespace object | |
42 | - **/ | |
43 | -ActionAppendConstant.prototype.call = function (parser, namespace) { | |
44 | - var items = [].concat(namespace[this.dest] || []); | |
45 | - items.push(this.constant); | |
46 | - namespace.set(this.dest, items); | |
47 | -}; |
images/node_modules/argparse/lib/action/count.js deleted
100644 → 0
1 | -/*:nodoc:* | |
2 | - * class ActionCount | |
3 | - * | |
4 | - * This counts the number of times a keyword argument occurs. | |
5 | - * For example, this is useful for increasing verbosity levels | |
6 | - * | |
7 | - * This class inherided from [[Action]] | |
8 | - * | |
9 | - **/ | |
10 | -'use strict'; | |
11 | - | |
12 | -var util = require('util'); | |
13 | - | |
14 | -var Action = require('../action'); | |
15 | - | |
16 | -/*:nodoc:* | |
17 | - * new ActionCount(options) | |
18 | - * - options (object): options hash see [[Action.new]] | |
19 | - * | |
20 | - **/ | |
21 | -var ActionCount = module.exports = function ActionCount(options) { | |
22 | - options = options || {}; | |
23 | - options.nargs = 0; | |
24 | - | |
25 | - Action.call(this, options); | |
26 | -}; | |
27 | -util.inherits(ActionCount, Action); | |
28 | - | |
29 | -/*:nodoc:* | |
30 | - * ActionCount#call(parser, namespace, values, optionString) -> Void | |
31 | - * - parser (ArgumentParser): current parser | |
32 | - * - namespace (Namespace): namespace for output data | |
33 | - * - values (Array): parsed values | |
34 | - * - optionString (Array): input option string(not parsed) | |
35 | - * | |
36 | - * Call the action. Save result in namespace object | |
37 | - **/ | |
38 | -ActionCount.prototype.call = function (parser, namespace) { | |
39 | - namespace.set(this.dest, (namespace[this.dest] || 0) + 1); | |
40 | -}; |
images/node_modules/argparse/lib/action/help.js deleted
100644 → 0
1 | -/*:nodoc:* | |
2 | - * class ActionHelp | |
3 | - * | |
4 | - * Support action for printing help | |
5 | - * This class inherided from [[Action]] | |
6 | - **/ | |
7 | -'use strict'; | |
8 | - | |
9 | -var util = require('util'); | |
10 | - | |
11 | -var Action = require('../action'); | |
12 | - | |
13 | -// Constants | |
14 | -var $$ = require('../const'); | |
15 | - | |
16 | -/*:nodoc:* | |
17 | - * new ActionHelp(options) | |
18 | - * - options (object): options hash see [[Action.new]] | |
19 | - * | |
20 | - **/ | |
21 | -var ActionHelp = module.exports = function ActionHelp(options) { | |
22 | - options = options || {}; | |
23 | - if (options.defaultValue !== null) { | |
24 | - options.defaultValue = options.defaultValue; | |
25 | - } | |
26 | - else { | |
27 | - options.defaultValue = $$.SUPPRESS; | |
28 | - } | |
29 | - options.dest = (options.dest !== null ? options.dest: $$.SUPPRESS); | |
30 | - options.nargs = 0; | |
31 | - Action.call(this, options); | |
32 | - | |
33 | -}; | |
34 | -util.inherits(ActionHelp, Action); | |
35 | - | |
36 | -/*:nodoc:* | |
37 | - * ActionHelp#call(parser, namespace, values, optionString) | |
38 | - * - parser (ArgumentParser): current parser | |
39 | - * - namespace (Namespace): namespace for output data | |
40 | - * - values (Array): parsed values | |
41 | - * - optionString (Array): input option string(not parsed) | |
42 | - * | |
43 | - * Print help and exit | |
44 | - **/ | |
45 | -ActionHelp.prototype.call = function (parser) { | |
46 | - parser.printHelp(); | |
47 | - parser.exit(); | |
48 | -}; |
images/node_modules/argparse/lib/action/store.js deleted
100644 → 0
1 | -/*:nodoc:* | |
2 | - * class ActionStore | |
3 | - * | |
4 | - * This action just stores the argument’s value. This is the default action. | |
5 | - * | |
6 | - * This class inherited from [[Action]] | |
7 | - * | |
8 | - **/ | |
9 | -'use strict'; | |
10 | - | |
11 | -var util = require('util'); | |
12 | - | |
13 | -var Action = require('../action'); | |
14 | - | |
15 | -// Constants | |
16 | -var $$ = require('../const'); | |
17 | - | |
18 | - | |
19 | -/*:nodoc:* | |
20 | - * new ActionStore(options) | |
21 | - * - options (object): options hash see [[Action.new]] | |
22 | - * | |
23 | - **/ | |
24 | -var ActionStore = module.exports = function ActionStore(options) { | |
25 | - options = options || {}; | |
26 | - if (this.nargs <= 0) { | |
27 | - throw new Error('nargs for store actions must be > 0; if you ' + | |
28 | - 'have nothing to store, actions such as store ' + | |
29 | - 'true or store const may be more appropriate'); | |
30 | - | |
31 | - } | |
32 | - if (this.constant !== undefined && this.nargs !== $$.OPTIONAL) { | |
33 | - throw new Error('nargs must be OPTIONAL to supply const'); | |
34 | - } | |
35 | - Action.call(this, options); | |
36 | -}; | |
37 | -util.inherits(ActionStore, Action); | |
38 | - | |
39 | -/*:nodoc:* | |
40 | - * ActionStore#call(parser, namespace, values, optionString) -> Void | |
41 | - * - parser (ArgumentParser): current parser | |
42 | - * - namespace (Namespace): namespace for output data | |
43 | - * - values (Array): parsed values | |
44 | - * - optionString (Array): input option string(not parsed) | |
45 | - * | |
46 | - * Call the action. Save result in namespace object | |
47 | - **/ | |
48 | -ActionStore.prototype.call = function (parser, namespace, values) { | |
49 | - namespace.set(this.dest, values); | |
50 | -}; |
images/node_modules/argparse/lib/action/store/constant.js deleted
100644 → 0
1 | -/*:nodoc:* | |
2 | - * class ActionStoreConstant | |
3 | - * | |
4 | - * This action stores the value specified by the const keyword argument. | |
5 | - * (Note that the const keyword argument defaults to the rather unhelpful null.) | |
6 | - * The 'store_const' action is most commonly used with optional | |
7 | - * arguments that specify some sort of flag. | |
8 | - * | |
9 | - * This class inherited from [[Action]] | |
10 | - **/ | |
11 | -'use strict'; | |
12 | - | |
13 | -var util = require('util'); | |
14 | - | |
15 | -var Action = require('../../action'); | |
16 | - | |
17 | -/*:nodoc:* | |
18 | - * new ActionStoreConstant(options) | |
19 | - * - options (object): options hash see [[Action.new]] | |
20 | - * | |
21 | - **/ | |
22 | -var ActionStoreConstant = module.exports = function ActionStoreConstant(options) { | |
23 | - options = options || {}; | |
24 | - options.nargs = 0; | |
25 | - if (options.constant === undefined) { | |
26 | - throw new Error('constant option is required for storeAction'); | |
27 | - } | |
28 | - Action.call(this, options); | |
29 | -}; | |
30 | -util.inherits(ActionStoreConstant, Action); | |
31 | - | |
32 | -/*:nodoc:* | |
33 | - * ActionStoreConstant#call(parser, namespace, values, optionString) -> Void | |
34 | - * - parser (ArgumentParser): current parser | |
35 | - * - namespace (Namespace): namespace for output data | |
36 | - * - values (Array): parsed values | |
37 | - * - optionString (Array): input option string(not parsed) | |
38 | - * | |
39 | - * Call the action. Save result in namespace object | |
40 | - **/ | |
41 | -ActionStoreConstant.prototype.call = function (parser, namespace) { | |
42 | - namespace.set(this.dest, this.constant); | |
43 | -}; |
images/node_modules/argparse/lib/action/store/false.js deleted
100644 → 0
1 | -/*:nodoc:* | |
2 | - * class ActionStoreFalse | |
3 | - * | |
4 | - * This action store the values False respectively. | |
5 | - * This is special cases of 'storeConst' | |
6 | - * | |
7 | - * This class inherited from [[Action]] | |
8 | - **/ | |
9 | - | |
10 | -'use strict'; | |
11 | - | |
12 | -var util = require('util'); | |
13 | - | |
14 | -var ActionStoreConstant = require('./constant'); | |
15 | - | |
16 | -/*:nodoc:* | |
17 | - * new ActionStoreFalse(options) | |
18 | - * - options (object): hash of options see [[Action.new]] | |
19 | - * | |
20 | - **/ | |
21 | -var ActionStoreFalse = module.exports = function ActionStoreFalse(options) { | |
22 | - options = options || {}; | |
23 | - options.constant = false; | |
24 | - options.defaultValue = options.defaultValue !== null ? options.defaultValue: true; | |
25 | - ActionStoreConstant.call(this, options); | |
26 | -}; | |
27 | -util.inherits(ActionStoreFalse, ActionStoreConstant); |
images/node_modules/argparse/lib/action/store/true.js deleted
100644 → 0
1 | -/*:nodoc:* | |
2 | - * class ActionStoreTrue | |
3 | - * | |
4 | - * This action store the values True respectively. | |
5 | - * This isspecial cases of 'storeConst' | |
6 | - * | |
7 | - * This class inherited from [[Action]] | |
8 | - **/ | |
9 | -'use strict'; | |
10 | - | |
11 | -var util = require('util'); | |
12 | - | |
13 | -var ActionStoreConstant = require('./constant'); | |
14 | - | |
15 | -/*:nodoc:* | |
16 | - * new ActionStoreTrue(options) | |
17 | - * - options (object): options hash see [[Action.new]] | |
18 | - * | |
19 | - **/ | |
20 | -var ActionStoreTrue = module.exports = function ActionStoreTrue(options) { | |
21 | - options = options || {}; | |
22 | - options.constant = true; | |
23 | - options.defaultValue = options.defaultValue !== null ? options.defaultValue: false; | |
24 | - ActionStoreConstant.call(this, options); | |
25 | -}; | |
26 | -util.inherits(ActionStoreTrue, ActionStoreConstant); |
images/node_modules/argparse/lib/action/subparsers.js deleted
100644 → 0
1 | -/** internal | |
2 | - * class ActionSubparsers | |
3 | - * | |
4 | - * Support the creation of such sub-commands with the addSubparsers() | |
5 | - * | |
6 | - * This class inherited from [[Action]] | |
7 | - **/ | |
8 | -'use strict'; | |
9 | - | |
10 | -var util = require('util'); | |
11 | -var format = require('util').format; | |
12 | -var _ = require('underscore'); | |
13 | - | |
14 | - | |
15 | -var Action = require('../action'); | |
16 | - | |
17 | -// Constants | |
18 | -var $$ = require('../const'); | |
19 | - | |
20 | -// Errors | |
21 | -var argumentErrorHelper = require('../argument/error'); | |
22 | - | |
23 | - | |
24 | -/*:nodoc:* | |
25 | - * new ChoicesPseudoAction(name, help) | |
26 | - * | |
27 | - * Create pseudo action for correct help text | |
28 | - * | |
29 | - **/ | |
30 | -var ChoicesPseudoAction = function (name, help) { | |
31 | - var options = { | |
32 | - optionStrings: [], | |
33 | - dest: name, | |
34 | - help: help | |
35 | - }; | |
36 | - | |
37 | - Action.call(this, options); | |
38 | -}; | |
39 | -util.inherits(ChoicesPseudoAction, Action); | |
40 | - | |
41 | -/** | |
42 | - * new ActionSubparsers(options) | |
43 | - * - options (object): options hash see [[Action.new]] | |
44 | - * | |
45 | - **/ | |
46 | -var ActionSubparsers = module.exports = function ActionSubparsers(options) { | |
47 | - options = options || {}; | |
48 | - options.dest = options.dest || $$.SUPPRESS; | |
49 | - options.nargs = $$.PARSER; | |
50 | - | |
51 | - this.debug = (options.debug === true); | |
52 | - | |
53 | - this._progPrefix = options.prog; | |
54 | - this._parserClass = options.parserClass; | |
55 | - this._nameParserMap = {}; | |
56 | - this._choicesActions = []; | |
57 | - | |
58 | - options.choices = this._nameParserMap; | |
59 | - Action.call(this, options); | |
60 | -}; | |
61 | -util.inherits(ActionSubparsers, Action); | |
62 | - | |
63 | -/*:nodoc:* | |
64 | - * ActionSubparsers#addParser(name, options) -> ArgumentParser | |
65 | - * - name (string): sub-command name | |
66 | - * - options (object): see [[ArgumentParser.new]] | |
67 | - * | |
68 | - * Note: | |
69 | - * addParser supports an additional aliases option, | |
70 | - * which allows multiple strings to refer to the same subparser. | |
71 | - * This example, like svn, aliases co as a shorthand for checkout | |
72 | - * | |
73 | - **/ | |
74 | -ActionSubparsers.prototype.addParser = function (name, options) { | |
75 | - var parser; | |
76 | - | |
77 | - var self = this; | |
78 | - | |
79 | - options = options || {}; | |
80 | - | |
81 | - options.debug = (this.debug === true); | |
82 | - | |
83 | - // set program from the existing prefix | |
84 | - if (!options.prog) { | |
85 | - options.prog = this._progPrefix + ' ' + name; | |
86 | - } | |
87 | - | |
88 | - var aliases = options.aliases || []; | |
89 | - | |
90 | - // create a pseudo-action to hold the choice help | |
91 | - if (!!options.help || _.isString(options.help)) { | |
92 | - var help = options.help; | |
93 | - delete options.help; | |
94 | - | |
95 | - var choiceAction = new ChoicesPseudoAction(name, help); | |
96 | - this._choicesActions.push(choiceAction); | |
97 | - } | |
98 | - | |
99 | - // create the parser and add it to the map | |
100 | - parser = new this._parserClass(options); | |
101 | - this._nameParserMap[name] = parser; | |
102 | - | |
103 | - // make parser available under aliases also | |
104 | - aliases.forEach(function (alias) { | |
105 | - self._nameParserMap[alias] = parser; | |
106 | - }); | |
107 | - | |
108 | - return parser; | |
109 | -}; | |
110 | - | |
111 | -ActionSubparsers.prototype._getSubactions = function () { | |
112 | - return this._choicesActions; | |
113 | -}; | |
114 | - | |
115 | -/*:nodoc:* | |
116 | - * ActionSubparsers#call(parser, namespace, values, optionString) -> Void | |
117 | - * - parser (ArgumentParser): current parser | |
118 | - * - namespace (Namespace): namespace for output data | |
119 | - * - values (Array): parsed values | |
120 | - * - optionString (Array): input option string(not parsed) | |
121 | - * | |
122 | - * Call the action. Parse input aguments | |
123 | - **/ | |
124 | -ActionSubparsers.prototype.call = function (parser, namespace, values) { | |
125 | - var parserName = values[0]; | |
126 | - var argStrings = values.slice(1); | |
127 | - | |
128 | - // set the parser name if requested | |
129 | - if (this.dest !== $$.SUPPRESS) { | |
130 | - namespace[this.dest] = parserName; | |
131 | - } | |
132 | - | |
133 | - // select the parser | |
134 | - if (!!this._nameParserMap[parserName]) { | |
135 | - parser = this._nameParserMap[parserName]; | |
136 | - } else { | |
137 | - throw argumentErrorHelper(format( | |
138 | - 'Unknown parser "%s" (choices: [%s]).', | |
139 | - parserName, | |
140 | - _.keys(this._nameParserMap).join(', ') | |
141 | - )); | |
142 | - } | |
143 | - | |
144 | - // parse all the remaining options into the namespace | |
145 | - parser.parseArgs(argStrings, namespace); | |
146 | -}; | |
147 | - | |
148 | - |
images/node_modules/argparse/lib/action/version.js deleted
100644 → 0
1 | -/*:nodoc:* | |
2 | - * class ActionVersion | |
3 | - * | |
4 | - * Support action for printing program version | |
5 | - * This class inherited from [[Action]] | |
6 | - **/ | |
7 | -'use strict'; | |
8 | - | |
9 | -var util = require('util'); | |
10 | - | |
11 | -var Action = require('../action'); | |
12 | - | |
13 | -// | |
14 | -// Constants | |
15 | -// | |
16 | -var $$ = require('../const'); | |
17 | - | |
18 | -/*:nodoc:* | |
19 | - * new ActionVersion(options) | |
20 | - * - options (object): options hash see [[Action.new]] | |
21 | - * | |
22 | - **/ | |
23 | -var ActionVersion = module.exports = function ActionVersion(options) { | |
24 | - options = options || {}; | |
25 | - options.defaultValue = (!!options.defaultValue ? options.defaultValue: $$.SUPPRESS); | |
26 | - options.dest = (options.dest || $$.SUPPRESS); | |
27 | - options.nargs = 0; | |
28 | - this.version = options.version; | |
29 | - Action.call(this, options); | |
30 | -}; | |
31 | -util.inherits(ActionVersion, Action); | |
32 | - | |
33 | -/*:nodoc:* | |
34 | - * ActionVersion#call(parser, namespace, values, optionString) -> Void | |
35 | - * - parser (ArgumentParser): current parser | |
36 | - * - namespace (Namespace): namespace for output data | |
37 | - * - values (Array): parsed values | |
38 | - * - optionString (Array): input option string(not parsed) | |
39 | - * | |
40 | - * Print version and exit | |
41 | - **/ | |
42 | -ActionVersion.prototype.call = function (parser) { | |
43 | - var version = this.version || parser.version; | |
44 | - var formatter = parser._getFormatter(); | |
45 | - formatter.addText(version); | |
46 | - parser.exit(0, formatter.formatHelp()); | |
47 | -}; | |
48 | - | |
49 | - | |
50 | - |
images/node_modules/argparse/lib/action_container.js deleted
100644 → 0
1 | -/** internal | |
2 | - * class ActionContainer | |
3 | - * | |
4 | - * Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]] | |
5 | - **/ | |
6 | - | |
7 | -'use strict'; | |
8 | - | |
9 | -var format = require('util').format; | |
10 | -var _ = require('underscore'); | |
11 | - | |
12 | -_.str = require('underscore.string'); | |
13 | - | |
14 | -// Constants | |
15 | -var $$ = require('./const'); | |
16 | - | |
17 | -//Actions | |
18 | -var ActionHelp = require('./action/help'); | |
19 | -var ActionAppend = require('./action/append'); | |
20 | -var ActionAppendConstant = require('./action/append/constant'); | |
21 | -var ActionCount = require('./action/count'); | |
22 | -var ActionStore = require('./action/store'); | |
23 | -var ActionStoreConstant = require('./action/store/constant'); | |
24 | -var ActionStoreTrue = require('./action/store/true'); | |
25 | -var ActionStoreFalse = require('./action/store/false'); | |
26 | -var ActionVersion = require('./action/version'); | |
27 | -var ActionSubparsers = require('./action/subparsers'); | |
28 | - | |
29 | -// Errors | |
30 | -var argumentErrorHelper = require('./argument/error'); | |
31 | - | |
32 | - | |
33 | - | |
34 | -/** | |
35 | - * new ActionContainer(options) | |
36 | - * | |
37 | - * Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]] | |
38 | - * | |
39 | - * ##### Options: | |
40 | - * | |
41 | - * - `description` -- A description of what the program does | |
42 | - * - `prefixChars` -- Characters that prefix optional arguments | |
43 | - * - `argumentDefault` -- The default value for all arguments | |
44 | - * - `conflictHandler` -- The conflict handler to use for duplicate arguments | |
45 | - **/ | |
46 | -var ActionContainer = module.exports = function ActionContainer(options) { | |
47 | - options = options || {}; | |
48 | - | |
49 | - this.description = options.description; | |
50 | - this.argumentDefault = options.argumentDefault; | |
51 | - this.prefixChars = options.prefixChars || ''; | |
52 | - this.conflictHandler = options.conflictHandler; | |
53 | - | |
54 | - // set up registries | |
55 | - this._registries = {}; | |
56 | - | |
57 | - // register actions | |
58 | - this.register('action', null, ActionStore); | |
59 | - this.register('action', 'store', ActionStore); | |
60 | - this.register('action', 'storeConst', ActionStoreConstant); | |
61 | - this.register('action', 'storeTrue', ActionStoreTrue); | |
62 | - this.register('action', 'storeFalse', ActionStoreFalse); | |
63 | - this.register('action', 'append', ActionAppend); | |
64 | - this.register('action', 'appendConst', ActionAppendConstant); | |
65 | - this.register('action', 'count', ActionCount); | |
66 | - this.register('action', 'help', ActionHelp); | |
67 | - this.register('action', 'version', ActionVersion); | |
68 | - this.register('action', 'parsers', ActionSubparsers); | |
69 | - | |
70 | - // raise an exception if the conflict handler is invalid | |
71 | - this._getHandler(); | |
72 | - | |
73 | - // action storage | |
74 | - this._actions = []; | |
75 | - this._optionStringActions = {}; | |
76 | - | |
77 | - // groups | |
78 | - this._actionGroups = []; | |
79 | - this._mutuallyExclusiveGroups = []; | |
80 | - | |
81 | - // defaults storage | |
82 | - this._defaults = {}; | |
83 | - | |
84 | - // determines whether an "option" looks like a negative number | |
85 | - // -1, -1.5 -5e+4 | |
86 | - this._regexpNegativeNumber = new RegExp('^[-]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$'); | |
87 | - | |
88 | - // whether or not there are any optionals that look like negative | |
89 | - // numbers -- uses a list so it can be shared and edited | |
90 | - this._hasNegativeNumberOptionals = []; | |
91 | -}; | |
92 | - | |
93 | -// Groups must be required, then ActionContainer already defined | |
94 | -var ArgumentGroup = require('./argument/group'); | |
95 | -var MutuallyExclusiveGroup = require('./argument/exclusive'); | |
96 | - | |
97 | -// | |
98 | -// Registration methods | |
99 | -// | |
100 | - | |
101 | -/** | |
102 | - * ActionContainer#register(registryName, value, object) -> Void | |
103 | - * - registryName (String) : object type action|type | |
104 | - * - value (string) : keyword | |
105 | - * - object (Object|Function) : handler | |
106 | - * | |
107 | - * Register handlers | |
108 | - **/ | |
109 | -ActionContainer.prototype.register = function (registryName, value, object) { | |
110 | - this._registries[registryName] = this._registries[registryName] || {}; | |
111 | - this._registries[registryName][value] = object; | |
112 | -}; | |
113 | - | |
114 | -ActionContainer.prototype._registryGet = function (registryName, value, defaultValue) { | |
115 | - if (3 > arguments.length) { | |
116 | - defaultValue = null; | |
117 | - } | |
118 | - return this._registries[registryName][value] || defaultValue; | |
119 | -}; | |
120 | - | |
121 | -// | |
122 | -// Namespace default accessor methods | |
123 | -// | |
124 | - | |
125 | -/** | |
126 | - * ActionContainer#setDefaults(options) -> Void | |
127 | - * - options (object):hash of options see [[Action.new]] | |
128 | - * | |
129 | - * Set defaults | |
130 | - **/ | |
131 | -ActionContainer.prototype.setDefaults = function (options) { | |
132 | - options = options || {}; | |
133 | - for (var property in options) { | |
134 | - this._defaults[property] = options[property]; | |
135 | - } | |
136 | - | |
137 | - // if these defaults match any existing arguments, replace the previous | |
138 | - // default on the object with the new one | |
139 | - this._actions.forEach(function (action) { | |
140 | - if (action.dest in options) { | |
141 | - action.defaultValue = options[action.dest]; | |
142 | - } | |
143 | - }); | |
144 | -}; | |
145 | - | |
146 | -/** | |
147 | - * ActionContainer#getDefault(dest) -> Mixed | |
148 | - * - dest (string): action destination | |
149 | - * | |
150 | - * Return action default value | |
151 | - **/ | |
152 | -ActionContainer.prototype.getDefault = function (dest) { | |
153 | - var result = (_.has(this._defaults, dest)) ? this._defaults[dest] : null; | |
154 | - | |
155 | - this._actions.forEach(function (action) { | |
156 | - if (action.dest === dest && _.has(action, 'defaultValue')) { | |
157 | - result = action.defaultValue; | |
158 | - } | |
159 | - }); | |
160 | - | |
161 | - return result; | |
162 | -}; | |
163 | -// | |
164 | -// Adding argument actions | |
165 | -// | |
166 | - | |
167 | -/** | |
168 | - * ActionContainer#addArgument(args, options) -> Object | |
169 | - * - args (Array): array of argument keys | |
170 | - * - options (Object): action objects see [[Action.new]] | |
171 | - * | |
172 | - * #### Examples | |
173 | - * - addArgument([-f, --foo], {action:'store', defaultValue=1, ...}) | |
174 | - * - addArgument(['bar'], action: 'store', nargs:1, ...}) | |
175 | - **/ | |
176 | -ActionContainer.prototype.addArgument = function (args, options) { | |
177 | - args = args; | |
178 | - options = options || {}; | |
179 | - | |
180 | - if (!_.isArray(args)) { | |
181 | - throw new TypeError('addArgument first argument should be an array'); | |
182 | - } | |
183 | - if (!_.isObject(options) || _.isArray(options)) { | |
184 | - throw new TypeError('addArgument second argument should be a hash'); | |
185 | - } | |
186 | - | |
187 | - // if no positional args are supplied or only one is supplied and | |
188 | - // it doesn't look like an option string, parse a positional argument | |
189 | - if (!args || args.length === 1 && this.prefixChars.indexOf(args[0][0]) < 0) { | |
190 | - if (args && !!options.dest) { | |
191 | - throw new Error('dest supplied twice for positional argument'); | |
192 | - } | |
193 | - options = this._getPositional(args, options); | |
194 | - | |
195 | - // otherwise, we're adding an optional argument | |
196 | - } else { | |
197 | - options = this._getOptional(args, options); | |
198 | - } | |
199 | - | |
200 | - // if no default was supplied, use the parser-level default | |
201 | - if (_.isUndefined(options.defaultValue)) { | |
202 | - var dest = options.dest; | |
203 | - if (_.has(this._defaults, dest)) { | |
204 | - options.defaultValue = this._defaults[dest]; | |
205 | - } else if (!_.isUndefined(this.argumentDefault)) { | |
206 | - options.defaultValue = this.argumentDefault; | |
207 | - } | |
208 | - } | |
209 | - | |
210 | - // create the action object, and add it to the parser | |
211 | - var ActionClass = this._popActionClass(options); | |
212 | - if (! _.isFunction(ActionClass)) { | |
213 | - throw new Error(format('Unknown action "%s".', ActionClass)); | |
214 | - } | |
215 | - var action = new ActionClass(options); | |
216 | - | |
217 | - // throw an error if the action type is not callable | |
218 | - var typeFunction = this._registryGet('type', action.type, action.type); | |
219 | - if (!_.isFunction(typeFunction)) { | |
220 | - throw new Error(format('"%s" is not callable', typeFunction)); | |
221 | - } | |
222 | - | |
223 | - return this._addAction(action); | |
224 | -}; | |
225 | - | |
226 | -/** | |
227 | - * ActionContainer#addArgumentGroup(options) -> ArgumentGroup | |
228 | - * - options (Object): hash of options see [[ArgumentGroup.new]] | |
229 | - * | |
230 | - * Create new arguments groups | |
231 | - **/ | |
232 | -ActionContainer.prototype.addArgumentGroup = function (options) { | |
233 | - var group = new ArgumentGroup(this, options); | |
234 | - this._actionGroups.push(group); | |
235 | - return group; | |
236 | -}; | |
237 | - | |
238 | -/** | |
239 | - * ActionContainer#addMutuallyExclusiveGroup(options) -> ArgumentGroup | |
240 | - * - options (Object): {required: false} | |
241 | - * | |
242 | - * Create new mutual exclusive groups | |
243 | - **/ | |
244 | -ActionContainer.prototype.addMutuallyExclusiveGroup = function (options) { | |
245 | - var group = new MutuallyExclusiveGroup(this, options); | |
246 | - this._mutuallyExclusiveGroups.push(group); | |
247 | - return group; | |
248 | -}; | |
249 | - | |
250 | -ActionContainer.prototype._addAction = function (action) { | |
251 | - var self = this; | |
252 | - | |
253 | - // resolve any conflicts | |
254 | - this._checkConflict(action); | |
255 | - | |
256 | - // add to actions list | |
257 | - this._actions.push(action); | |
258 | - action.container = this; | |
259 | - | |
260 | - // index the action by any option strings it has | |
261 | - action.optionStrings.forEach(function (optionString) { | |
262 | - self._optionStringActions[optionString] = action; | |
263 | - }); | |
264 | - | |
265 | - // set the flag if any option strings look like negative numbers | |
266 | - action.optionStrings.forEach(function (optionString) { | |
267 | - if (optionString.match(self._regexpNegativeNumber)) { | |
268 | - if (!_.any(self._hasNegativeNumberOptionals)) { | |
269 | - self._hasNegativeNumberOptionals.push(true); | |
270 | - } | |
271 | - } | |
272 | - }); | |
273 | - | |
274 | - // return the created action | |
275 | - return action; | |
276 | -}; | |
277 | - | |
278 | -ActionContainer.prototype._removeAction = function (action) { | |
279 | - var actionIndex = this._actions.indexOf(action); | |
280 | - if (actionIndex >= 0) { | |
281 | - this._actions.splice(actionIndex, 1); | |
282 | - } | |
283 | -}; | |
284 | - | |
285 | -ActionContainer.prototype._addContainerActions = function (container) { | |
286 | - // collect groups by titles | |
287 | - var titleGroupMap = {}; | |
288 | - this._actionGroups.forEach(function (group) { | |
289 | - if (titleGroupMap[group.title]) { | |
290 | - throw new Error(format('Cannot merge actions - two groups are named "%s".', group.title)); | |
291 | - } | |
292 | - titleGroupMap[group.title] = group; | |
293 | - }); | |
294 | - | |
295 | - // map each action to its group | |
296 | - var groupMap = {}; | |
297 | - function actionHash(action) { | |
298 | - // unique (hopefully?) string suitable as dictionary key | |
299 | - return action.getName(); | |
300 | - } | |
301 | - container._actionGroups.forEach(function (group) { | |
302 | - // if a group with the title exists, use that, otherwise | |
303 | - // create a new group matching the container's group | |
304 | - if (!titleGroupMap[group.title]) { | |
305 | - titleGroupMap[group.title] = this.addArgumentGroup({ | |
306 | - title: group.title, | |
307 | - description: group.description | |
308 | - }); | |
309 | - } | |
310 | - | |
311 | - // map the actions to their new group | |
312 | - group._groupActions.forEach(function (action) { | |
313 | - groupMap[actionHash(action)] = titleGroupMap[group.title]; | |
314 | - }); | |
315 | - }, this); | |
316 | - | |
317 | - // add container's mutually exclusive groups | |
318 | - // NOTE: if add_mutually_exclusive_group ever gains title= and | |
319 | - // description= then this code will need to be expanded as above | |
320 | - var mutexGroup; | |
321 | - container._mutuallyExclusiveGroups.forEach(function (group) { | |
322 | - mutexGroup = this.addMutuallyExclusiveGroup({ | |
323 | - required: group.required | |
324 | - }); | |
325 | - // map the actions to their new mutex group | |
326 | - group._groupActions.forEach(function (action) { | |
327 | - groupMap[actionHash(action)] = mutexGroup; | |
328 | - }); | |
329 | - }, this); // forEach takes a 'this' argument | |
330 | - | |
331 | - // add all actions to this container or their group | |
332 | - container._actions.forEach(function (action) { | |
333 | - var key = actionHash(action); | |
334 | - if (!!groupMap[key]) { | |
335 | - groupMap[key]._addAction(action); | |
336 | - } | |
337 | - else | |
338 | - { | |
339 | - this._addAction(action); | |
340 | - } | |
341 | - }); | |
342 | -}; | |
343 | - | |
344 | -ActionContainer.prototype._getPositional = function (dest, options) { | |
345 | - if (_.isArray(dest)) { | |
346 | - dest = _.first(dest); | |
347 | - } | |
348 | - // make sure required is not specified | |
349 | - if (options.required) { | |
350 | - throw new Error('"required" is an invalid argument for positionals.'); | |
351 | - } | |
352 | - | |
353 | - // mark positional arguments as required if at least one is | |
354 | - // always required | |
355 | - if (options.nargs !== $$.OPTIONAL && options.nargs !== $$.ZERO_OR_MORE) { | |
356 | - options.required = true; | |
357 | - } | |
358 | - if (options.nargs === $$.ZERO_OR_MORE && options.defaultValue === undefined) { | |
359 | - options.required = true; | |
360 | - } | |
361 | - | |
362 | - // return the keyword arguments with no option strings | |
363 | - options.dest = dest; | |
364 | - options.optionStrings = []; | |
365 | - return options; | |
366 | -}; | |
367 | - | |
368 | -ActionContainer.prototype._getOptional = function (args, options) { | |
369 | - var prefixChars = this.prefixChars; | |
370 | - var optionStrings = []; | |
371 | - var optionStringsLong = []; | |
372 | - | |
373 | - // determine short and long option strings | |
374 | - args.forEach(function (optionString) { | |
375 | - // error on strings that don't start with an appropriate prefix | |
376 | - if (prefixChars.indexOf(optionString[0]) < 0) { | |
377 | - throw new Error(format('Invalid option string "%s": must start with a "%s".', | |
378 | - optionString, | |
379 | - prefixChars | |
380 | - )); | |
381 | - } | |
382 | - | |
383 | - // strings starting with two prefix characters are long options | |
384 | - optionStrings.push(optionString); | |
385 | - if (optionString.length > 1 && prefixChars.indexOf(optionString[1]) >= 0) { | |
386 | - optionStringsLong.push(optionString); | |
387 | - } | |
388 | - }); | |
389 | - | |
390 | - // infer dest, '--foo-bar' -> 'foo_bar' and '-x' -> 'x' | |
391 | - var dest = options.dest || null; | |
392 | - delete options.dest; | |
393 | - | |
394 | - if (!dest) { | |
395 | - var optionStringDest = optionStringsLong.length ? optionStringsLong[0] :optionStrings[0]; | |
396 | - dest = _.str.strip(optionStringDest, this.prefixChars); | |
397 | - | |
398 | - if (dest.length === 0) { | |
399 | - throw new Error( | |
400 | - format('dest= is required for options like "%s"', optionStrings.join(', ')) | |
401 | - ); | |
402 | - } | |
403 | - dest = dest.replace(/-/g, '_'); | |
404 | - } | |
405 | - | |
406 | - // return the updated keyword arguments | |
407 | - options.dest = dest; | |
408 | - options.optionStrings = optionStrings; | |
409 | - | |
410 | - return options; | |
411 | -}; | |
412 | - | |
413 | -ActionContainer.prototype._popActionClass = function (options, defaultValue) { | |
414 | - defaultValue = defaultValue || null; | |
415 | - | |
416 | - var action = (options.action || defaultValue); | |
417 | - delete options.action; | |
418 | - | |
419 | - var actionClass = this._registryGet('action', action, action); | |
420 | - return actionClass; | |
421 | -}; | |
422 | - | |
423 | -ActionContainer.prototype._getHandler = function () { | |
424 | - var handlerString = this.conflictHandler; | |
425 | - var handlerFuncName = "_handleConflict" + _.str.capitalize(handlerString); | |
426 | - var func = this[handlerFuncName]; | |
427 | - if (typeof func === 'undefined') { | |
428 | - var msg = "invalid conflict resolution value: " + handlerString; | |
429 | - throw new Error(msg); | |
430 | - } else { | |
431 | - return func; | |
432 | - } | |
433 | -}; | |
434 | - | |
435 | -ActionContainer.prototype._checkConflict = function (action) { | |
436 | - var optionStringActions = this._optionStringActions; | |
437 | - var conflictOptionals = []; | |
438 | - | |
439 | - // find all options that conflict with this option | |
440 | - // collect pairs, the string, and an existing action that it conflicts with | |
441 | - action.optionStrings.forEach(function (optionString) { | |
442 | - var conflOptional = optionStringActions[optionString]; | |
443 | - if (typeof conflOptional !== 'undefined') { | |
444 | - conflictOptionals.push([optionString, conflOptional]); | |
445 | - } | |
446 | - }); | |
447 | - | |
448 | - if (conflictOptionals.length > 0) { | |
449 | - var conflictHandler = this._getHandler(); | |
450 | - conflictHandler.call(this, action, conflictOptionals); | |
451 | - } | |
452 | -}; | |
453 | - | |
454 | -ActionContainer.prototype._handleConflictError = function (action, conflOptionals) { | |
455 | - var conflicts = _.map(conflOptionals, function (pair) {return pair[0]; }); | |
456 | - conflicts = conflicts.join(', '); | |
457 | - throw argumentErrorHelper( | |
458 | - action, | |
459 | - format('Conflicting option string(s): %s', conflicts) | |
460 | - ); | |
461 | -}; | |
462 | - | |
463 | -ActionContainer.prototype._handleConflictResolve = function (action, conflOptionals) { | |
464 | - // remove all conflicting options | |
465 | - var self = this; | |
466 | - conflOptionals.forEach(function (pair) { | |
467 | - var optionString = pair[0]; | |
468 | - var conflictingAction = pair[1]; | |
469 | - // remove the conflicting option string | |
470 | - var i = conflictingAction.optionStrings.indexOf(optionString); | |
471 | - if (i >= 0) { | |
472 | - conflictingAction.optionStrings.splice(i, 1); | |
473 | - } | |
474 | - delete self._optionStringActions[optionString]; | |
475 | - // if the option now has no option string, remove it from the | |
476 | - // container holding it | |
477 | - if (conflictingAction.optionStrings.length === 0) { | |
478 | - conflictingAction.container._removeAction(conflictingAction); | |
479 | - } | |
480 | - }); | |
481 | -}; |
images/node_modules/argparse/lib/argparse.js deleted
100644 → 0
1 | -'use strict'; | |
2 | - | |
3 | -module.exports.ArgumentParser = require('./argument_parser.js'); | |
4 | -module.exports.Namespace = require('./namespace'); | |
5 | -module.exports.Action = require('./action'); | |
6 | -module.exports.HelpFormatter = require('./help/formatter.js'); | |
7 | -module.exports.Const = require('./const.js'); | |
8 | - | |
9 | -module.exports.ArgumentDefaultsHelpFormatter = | |
10 | - require('./help/added_formatters.js').ArgumentDefaultsHelpFormatter; | |
11 | -module.exports.RawDescriptionHelpFormatter = | |
12 | - require('./help/added_formatters.js').RawDescriptionHelpFormatter; | |
13 | -module.exports.RawTextHelpFormatter = | |
14 | - require('./help/added_formatters.js').RawTextHelpFormatter; |
images/node_modules/argparse/lib/argument/error.js deleted
100644 → 0
1 | -'use strict'; | |
2 | - | |
3 | - | |
4 | -var format = require('util').format; | |
5 | - | |
6 | - | |
7 | -var ERR_CODE = 'ARGError'; | |
8 | - | |
9 | -/*:nodoc:* | |
10 | - * argumentError(argument, message) -> TypeError | |
11 | - * - argument (Object): action with broken argument | |
12 | - * - message (String): error message | |
13 | - * | |
14 | - * Error format helper. An error from creating or using an argument | |
15 | - * (optional or positional). The string value of this exception | |
16 | - * is the message, augmented with information | |
17 | - * about the argument that caused it. | |
18 | - * | |
19 | - * #####Example | |
20 | - * | |
21 | - * var argumentErrorHelper = require('./argument/error'); | |
22 | - * if (conflictOptionals.length > 0) { | |
23 | - * throw argumentErrorHelper( | |
24 | - * action, | |
25 | - * format('Conflicting option string(s): %s', conflictOptionals.join(', ')) | |
26 | - * ); | |
27 | - * } | |
28 | - * | |
29 | - **/ | |
30 | -module.exports = function (argument, message) { | |
31 | - var argumentName = null; | |
32 | - var errMessage; | |
33 | - var err; | |
34 | - | |
35 | - if (argument.getName) { | |
36 | - argumentName = argument.getName(); | |
37 | - } else { | |
38 | - argumentName = '' + argument; | |
39 | - } | |
40 | - | |
41 | - if (!argumentName) { | |
42 | - errMessage = message; | |
43 | - } else { | |
44 | - errMessage = format('argument "%s": %s', argumentName, message); | |
45 | - } | |
46 | - | |
47 | - err = new TypeError(errMessage); | |
48 | - err.code = ERR_CODE; | |
49 | - return err; | |
50 | -}; |
images/node_modules/argparse/lib/argument/exclusive.js deleted
100644 → 0
1 | -/** internal | |
2 | - * class MutuallyExclusiveGroup | |
3 | - * | |
4 | - * Group arguments. | |
5 | - * By default, ArgumentParser groups command-line arguments | |
6 | - * into “positional arguments” and “optional arguments” | |
7 | - * when displaying help messages. When there is a better | |
8 | - * conceptual grouping of arguments than this default one, | |
9 | - * appropriate groups can be created using the addArgumentGroup() method | |
10 | - * | |
11 | - * This class inherited from [[ArgumentContainer]] | |
12 | - **/ | |
13 | -'use strict'; | |
14 | - | |
15 | -var util = require('util'); | |
16 | - | |
17 | -var ArgumentGroup = require('./group'); | |
18 | - | |
19 | -/** | |
20 | - * new MutuallyExclusiveGroup(container, options) | |
21 | - * - container (object): main container | |
22 | - * - options (object): options.required -> true/false | |
23 | - * | |
24 | - * `required` could be an argument itself, but making it a property of | |
25 | - * the options argument is more consistent with the JS adaptation of the Python) | |
26 | - **/ | |
27 | -var MutuallyExclusiveGroup = module.exports = function MutuallyExclusiveGroup(container, options) { | |
28 | - var required; | |
29 | - options = options || {}; | |
30 | - required = options.required || false; | |
31 | - ArgumentGroup.call(this, container); | |
32 | - this.required = required; | |
33 | - | |
34 | -}; | |
35 | -util.inherits(MutuallyExclusiveGroup, ArgumentGroup); | |
36 | - | |
37 | - | |
38 | -MutuallyExclusiveGroup.prototype._addAction = function (action) { | |
39 | - var msg; | |
40 | - if (action.required) { | |
41 | - msg = 'mutually exclusive arguments must be optional'; | |
42 | - throw new Error(msg); | |
43 | - } | |
44 | - action = this._container._addAction(action); | |
45 | - this._groupActions.push(action); | |
46 | - return action; | |
47 | -}; | |
48 | - | |
49 | - | |
50 | -MutuallyExclusiveGroup.prototype._removeAction = function (action) { | |
51 | - this._container._removeAction(action); | |
52 | - this._groupActions.remove(action); | |
53 | -}; | |
54 | - |
images/node_modules/argparse/lib/argument/group.js deleted
100644 → 0
1 | -/** internal | |
2 | - * class ArgumentGroup | |
3 | - * | |
4 | - * Group arguments. | |
5 | - * By default, ArgumentParser groups command-line arguments | |
6 | - * into “positional arguments” and “optional arguments” | |
7 | - * when displaying help messages. When there is a better | |
8 | - * conceptual grouping of arguments than this default one, | |
9 | - * appropriate groups can be created using the addArgumentGroup() method | |
10 | - * | |
11 | - * This class inherited from [[ArgumentContainer]] | |
12 | - **/ | |
13 | -'use strict'; | |
14 | - | |
15 | -var util = require('util'); | |
16 | - | |
17 | -var ActionContainer = require('../action_container'); | |
18 | - | |
19 | - | |
20 | -/** | |
21 | - * new ArgumentGroup(container, options) | |
22 | - * - container (object): main container | |
23 | - * - options (object): hash of group options | |
24 | - * | |
25 | - * #### options | |
26 | - * - **prefixChars** group name prefix | |
27 | - * - **argumentDefault** default argument value | |
28 | - * - **title** group title | |
29 | - * - **description** group description | |
30 | - * | |
31 | - **/ | |
32 | -var ArgumentGroup = module.exports = function ArgumentGroup(container, options) { | |
33 | - | |
34 | - options = options || {}; | |
35 | - | |
36 | - // add any missing keyword arguments by checking the container | |
37 | - options.conflictHandler = (options.conflictHandler || container.conflictHandler); | |
38 | - options.prefixChars = (options.prefixChars || container.prefixChars); | |
39 | - options.argumentDefault = (options.argumentDefault || container.argumentDefault); | |
40 | - | |
41 | - ActionContainer.call(this, options); | |
42 | - | |
43 | - // group attributes | |
44 | - this.title = options.title; | |
45 | - this._groupActions = []; | |
46 | - | |
47 | - // share most attributes with the container | |
48 | - this._container = container; | |
49 | - this._registries = container._registries; | |
50 | - this._actions = container._actions; | |
51 | - this._optionStringActions = container._optionStringActions; | |
52 | - this._defaults = container._defaults; | |
53 | - this._hasNegativeNumberOptionals = container._hasNegativeNumberOptionals; | |
54 | - this._mutuallyExclusiveGroups = container._mutuallyExclusiveGroups; | |
55 | -}; | |
56 | -util.inherits(ArgumentGroup, ActionContainer); | |
57 | - | |
58 | - | |
59 | -ArgumentGroup.prototype._addAction = function (action) { | |
60 | - // Parent add action | |
61 | - action = ActionContainer.prototype._addAction.call(this, action); | |
62 | - this._groupActions.push(action); | |
63 | - return action; | |
64 | -}; | |
65 | - | |
66 | - | |
67 | -ArgumentGroup.prototype._removeAction = function (action) { | |
68 | - // Parent remove action | |
69 | - ActionContainer.prototype._removeAction.call(this, action); | |
70 | - var actionIndex = this._groupActions.indexOf(action); | |
71 | - if (actionIndex >= 0) { | |
72 | - this._groupActions.splice(actionIndex, 1); | |
73 | - } | |
74 | -}; | |
75 | - |
images/node_modules/argparse/lib/argument_parser.js deleted
100644 → 0
1 | -/** | |
2 | - * class ArgumentParser | |
3 | - * | |
4 | - * Object for parsing command line strings into js objects. | |
5 | - * | |
6 | - * Inherited from [[ActionContainer]] | |
7 | - **/ | |
8 | -'use strict'; | |
9 | - | |
10 | -var util = require('util'); | |
11 | -var format = require('util').format; | |
12 | -var Path = require('path'); | |
13 | - | |
14 | -var _ = require('underscore'); | |
15 | -_.str = require('underscore.string'); | |
16 | - | |
17 | -// Constants | |
18 | -var $$ = require('./const'); | |
19 | - | |
20 | -var ActionContainer = require('./action_container'); | |
21 | - | |
22 | -// Errors | |
23 | -var argumentErrorHelper = require('./argument/error'); | |
24 | - | |
25 | -var HelpFormatter = require('./help/formatter'); | |
26 | - | |
27 | -var Namespace = require('./namespace'); | |
28 | - | |
29 | - | |
30 | -/** | |
31 | - * new ArgumentParser(options) | |
32 | - * | |
33 | - * Create a new ArgumentParser object. | |
34 | - * | |
35 | - * ##### Options: | |
36 | - * - `prog` The name of the program (default: Path.basename(process.argv[1])) | |
37 | - * - `usage` A usage message (default: auto-generated from arguments) | |
38 | - * - `description` A description of what the program does | |
39 | - * - `epilog` Text following the argument descriptions | |
40 | - * - `parents` Parsers whose arguments should be copied into this one | |
41 | - * - `formatterClass` HelpFormatter class for printing help messages | |
42 | - * - `prefixChars` Characters that prefix optional arguments | |
43 | - * - `fromfilePrefixChars` Characters that prefix files containing additional arguments | |
44 | - * - `argumentDefault` The default value for all arguments | |
45 | - * - `addHelp` Add a -h/-help option | |
46 | - * - `conflictHandler` Specifies how to handle conflicting argument names | |
47 | - * - `debug` Enable debug mode. Argument errors throw exception in | |
48 | - * debug mode and process.exit in normal. Used for development and | |
49 | - * testing (default: false) | |
50 | - * | |
51 | - * See also [original guide][1] | |
52 | - * | |
53 | - * [1]:http://docs.python.org/dev/library/argparse.html#argumentparser-objects | |
54 | - **/ | |
55 | -var ArgumentParser = module.exports = function ArgumentParser(options) { | |
56 | - var self = this; | |
57 | - options = options || {}; | |
58 | - | |
59 | - options.description = (options.description || null); | |
60 | - options.argumentDefault = (options.argumentDefault || null); | |
61 | - options.prefixChars = (options.prefixChars || '-'); | |
62 | - options.conflictHandler = (options.conflictHandler || 'error'); | |
63 | - ActionContainer.call(this, options); | |
64 | - | |
65 | - options.addHelp = (options.addHelp === undefined || !!options.addHelp); | |
66 | - options.parents = (options.parents || []); | |
67 | - // default program name | |
68 | - options.prog = (options.prog || Path.basename(process.argv[1])); | |
69 | - this.prog = options.prog; | |
70 | - this.usage = options.usage; | |
71 | - this.epilog = options.epilog; | |
72 | - this.version = options.version; | |
73 | - | |
74 | - this.debug = (options.debug === true); | |
75 | - | |
76 | - this.formatterClass = (options.formatterClass || HelpFormatter); | |
77 | - this.fromfilePrefixChars = options.fromfilePrefixChars || null; | |
78 | - this._positionals = this.addArgumentGroup({title: 'Positional arguments'}); | |
79 | - this._optionals = this.addArgumentGroup({title: 'Optional arguments'}); | |
80 | - this._subparsers = null; | |
81 | - | |
82 | - // register types | |
83 | - var FUNCTION_IDENTITY = function (o) { | |
84 | - return o; | |
85 | - }; | |
86 | - this.register('type', 'auto', FUNCTION_IDENTITY); | |
87 | - this.register('type', null, FUNCTION_IDENTITY); | |
88 | - this.register('type', 'int', function (x) { | |
89 | - var result = parseInt(x, 10); | |
90 | - if (isNaN(result)) { | |
91 | - throw new Error(x + ' is not a valid integer.'); | |
92 | - } | |
93 | - return result; | |
94 | - }); | |
95 | - this.register('type', 'float', function (x) { | |
96 | - var result = parseFloat(x); | |
97 | - if (isNaN(result)) { | |
98 | - throw new Error(x + ' is not a valid float.'); | |
99 | - } | |
100 | - return result; | |
101 | - }); | |
102 | - this.register('type', 'string', function (x) { | |
103 | - return '' + x; | |
104 | - }); | |
105 | - | |
106 | - // add help and version arguments if necessary | |
107 | - var defaultPrefix = (this.prefixChars.indexOf('-') > -1) ? '-' : this.prefixChars[0]; | |
108 | - if (options.addHelp) { | |
109 | - this.addArgument( | |
110 | - [defaultPrefix + 'h', defaultPrefix + defaultPrefix + 'help'], | |
111 | - { | |
112 | - action: 'help', | |
113 | - defaultValue: $$.SUPPRESS, | |
114 | - help: 'Show this help message and exit.' | |
115 | - } | |
116 | - ); | |
117 | - } | |
118 | - if (this.version !== undefined) { | |
119 | - this.addArgument( | |
120 | - [defaultPrefix + 'v', defaultPrefix + defaultPrefix + 'version'], | |
121 | - { | |
122 | - action: 'version', | |
123 | - version: this.version, | |
124 | - defaultValue: $$.SUPPRESS, | |
125 | - help: "Show program's version number and exit." | |
126 | - } | |
127 | - ); | |
128 | - } | |
129 | - | |
130 | - // add parent arguments and defaults | |
131 | - options.parents.forEach(function (parent) { | |
132 | - self._addContainerActions(parent); | |
133 | - if (parent._defaults !== undefined) { | |
134 | - for (var defaultKey in parent._defaults) { | |
135 | - if (parent._defaults.hasOwnProperty(defaultKey)) { | |
136 | - self._defaults[defaultKey] = parent._defaults[defaultKey]; | |
137 | - } | |
138 | - } | |
139 | - } | |
140 | - }); | |
141 | - | |
142 | -}; | |
143 | -util.inherits(ArgumentParser, ActionContainer); | |
144 | - | |
145 | -/** | |
146 | - * ArgumentParser#addSubparsers(options) -> [[ActionSubparsers]] | |
147 | - * - options (object): hash of options see [[ActionSubparsers.new]] | |
148 | - * | |
149 | - * See also [subcommands][1] | |
150 | - * | |
151 | - * [1]:http://docs.python.org/dev/library/argparse.html#sub-commands | |
152 | - **/ | |
153 | -ArgumentParser.prototype.addSubparsers = function (options) { | |
154 | - if (!!this._subparsers) { | |
155 | - this.error('Cannot have multiple subparser arguments.'); | |
156 | - } | |
157 | - | |
158 | - options = options || {}; | |
159 | - options.debug = (this.debug === true); | |
160 | - options.optionStrings = []; | |
161 | - options.parserClass = (options.parserClass || ArgumentParser); | |
162 | - | |
163 | - | |
164 | - if (!!options.title || !!options.description) { | |
165 | - | |
166 | - this._subparsers = this.addArgumentGroup({ | |
167 | - title: (options.title || 'subcommands'), | |
168 | - description: options.description | |
169 | - }); | |
170 | - delete options.title; | |
171 | - delete options.description; | |
172 | - | |
173 | - } else { | |
174 | - this._subparsers = this._positionals; | |
175 | - } | |
176 | - | |
177 | - // prog defaults to the usage message of this parser, skipping | |
178 | - // optional arguments and with no "usage:" prefix | |
179 | - if (!options.prog) { | |
180 | - var formatter = this._getFormatter(); | |
181 | - var positionals = this._getPositionalActions(); | |
182 | - var groups = this._mutuallyExclusiveGroups; | |
183 | - formatter.addUsage(this.usage, positionals, groups, ''); | |
184 | - options.prog = _.str.strip(formatter.formatHelp()); | |
185 | - } | |
186 | - | |
187 | - // create the parsers action and add it to the positionals list | |
188 | - var ParsersClass = this._popActionClass(options, 'parsers'); | |
189 | - var action = new ParsersClass(options); | |
190 | - this._subparsers._addAction(action); | |
191 | - | |
192 | - // return the created parsers action | |
193 | - return action; | |
194 | -}; | |
195 | - | |
196 | -ArgumentParser.prototype._addAction = function (action) { | |
197 | - if (action.isOptional()) { | |
198 | - this._optionals._addAction(action); | |
199 | - } else { | |
200 | - this._positionals._addAction(action); | |
201 | - } | |
202 | - return action; | |
203 | -}; | |
204 | - | |
205 | -ArgumentParser.prototype._getOptionalActions = function () { | |
206 | - return this._actions.filter(function (action) { | |
207 | - return action.isOptional(); | |
208 | - }); | |
209 | -}; | |
210 | - | |
211 | -ArgumentParser.prototype._getPositionalActions = function () { | |
212 | - return this._actions.filter(function (action) { | |
213 | - return action.isPositional(); | |
214 | - }); | |
215 | -}; | |
216 | - | |
217 | - | |
218 | -/** | |
219 | - * ArgumentParser#parseArgs(args, namespace) -> Namespace|Object | |
220 | - * - args (array): input elements | |
221 | - * - namespace (Namespace|Object): result object | |
222 | - * | |
223 | - * Parsed args and throws error if some arguments are not recognized | |
224 | - * | |
225 | - * See also [original guide][1] | |
226 | - * | |
227 | - * [1]:http://docs.python.org/dev/library/argparse.html#the-parse-args-method | |
228 | - **/ | |
229 | -ArgumentParser.prototype.parseArgs = function (args, namespace) { | |
230 | - var argv; | |
231 | - var result = this.parseKnownArgs(args, namespace); | |
232 | - | |
233 | - args = result[0]; | |
234 | - argv = result[1]; | |
235 | - if (argv && argv.length > 0) { | |
236 | - this.error( | |
237 | - format('Unrecognized arguments: %s.', argv.join(' ')) | |
238 | - ); | |
239 | - } | |
240 | - return args; | |
241 | -}; | |
242 | - | |
243 | -/** | |
244 | - * ArgumentParser#parseKnownArgs(args, namespace) -> array | |
245 | - * - args (array): input options | |
246 | - * - namespace (Namespace|Object): result object | |
247 | - * | |
248 | - * Parse known arguments and return tuple of result object | |
249 | - * and unknown args | |
250 | - * | |
251 | - * See also [original guide][1] | |
252 | - * | |
253 | - * [1]:http://docs.python.org/dev/library/argparse.html#partial-parsing | |
254 | - **/ | |
255 | -ArgumentParser.prototype.parseKnownArgs = function (args, namespace) { | |
256 | - var self = this; | |
257 | - | |
258 | - // args default to the system args | |
259 | - args = args || process.argv.slice(2); | |
260 | - | |
261 | - // default Namespace built from parser defaults | |
262 | - namespace = namespace || new Namespace(); | |
263 | - | |
264 | - self._actions.forEach(function (action) { | |
265 | - if (action.dest !== $$.SUPPRESS) { | |
266 | - if (!_.has(namespace, action.dest)) { | |
267 | - if (action.defaultValue !== $$.SUPPRESS) { | |
268 | - var defaultValue = action.defaultValue; | |
269 | - if (_.isString(action.defaultValue)) { | |
270 | - defaultValue = self._getValue(action, defaultValue); | |
271 | - } | |
272 | - namespace[action.dest] = defaultValue; | |
273 | - } | |
274 | - } | |
275 | - } | |
276 | - }); | |
277 | - | |
278 | - _.keys(self._defaults).forEach(function (dest) { | |
279 | - namespace[dest] = self._defaults[dest]; | |
280 | - }); | |
281 | - | |
282 | - // parse the arguments and exit if there are any errors | |
283 | - try { | |
284 | - var res = this._parseKnownArgs(args, namespace); | |
285 | - | |
286 | - namespace = res[0]; | |
287 | - args = res[1]; | |
288 | - if (_.has(namespace, $$._UNRECOGNIZED_ARGS_ATTR)) { | |
289 | - args = _.union(args, namespace[$$._UNRECOGNIZED_ARGS_ATTR]); | |
290 | - delete namespace[$$._UNRECOGNIZED_ARGS_ATTR]; | |
291 | - } | |
292 | - return [namespace, args]; | |
293 | - } catch (e) { | |
294 | - this.error(e); | |
295 | - } | |
296 | -}; | |
297 | - | |
298 | -ArgumentParser.prototype._parseKnownArgs = function (argStrings, namespace) { | |
299 | - var self = this; | |
300 | - | |
301 | - var extras = []; | |
302 | - | |
303 | - // replace arg strings that are file references | |
304 | - if (this.fromfilePrefixChars !== null) { | |
305 | - argStrings = this._readArgsFromFiles(argStrings); | |
306 | - } | |
307 | - // map all mutually exclusive arguments to the other arguments | |
308 | - // they can't occur with | |
309 | - // Python has 'conflicts = action_conflicts.setdefault(mutex_action, [])' | |
310 | - // though I can't conceive of a way in which an action could be a member | |
311 | - // of two different mutually exclusive groups. | |
312 | - | |
313 | - function actionHash(action) { | |
314 | - // some sort of hashable key for this action | |
315 | - // action itself cannot be a key in actionConflicts | |
316 | - // I think getName() (join of optionStrings) is unique enough | |
317 | - return action.getName(); | |
318 | - } | |
319 | - | |
320 | - var conflicts, key; | |
321 | - var actionConflicts = {}; | |
322 | - | |
323 | - this._mutuallyExclusiveGroups.forEach(function (mutexGroup) { | |
324 | - mutexGroup._groupActions.forEach(function (mutexAction, i, groupActions) { | |
325 | - key = actionHash(mutexAction); | |
326 | - if (!_.has(actionConflicts, key)) { | |
327 | - actionConflicts[key] = []; | |
328 | - } | |
329 | - conflicts = actionConflicts[key]; | |
330 | - conflicts.push.apply(conflicts, groupActions.slice(0, i)); | |
331 | - conflicts.push.apply(conflicts, groupActions.slice(i + 1)); | |
332 | - }); | |
333 | - }); | |
334 | - | |
335 | - // find all option indices, and determine the arg_string_pattern | |
336 | - // which has an 'O' if there is an option at an index, | |
337 | - // an 'A' if there is an argument, or a '-' if there is a '--' | |
338 | - var optionStringIndices = {}; | |
339 | - | |
340 | - var argStringPatternParts = []; | |
341 | - | |
342 | - argStrings.forEach(function (argString, argStringIndex) { | |
343 | - if (argString === '--') { | |
344 | - argStringPatternParts.push('-'); | |
345 | - while (argStringIndex < argStrings.length) { | |
346 | - argStringPatternParts.push('A'); | |
347 | - argStringIndex++; | |
348 | - } | |
349 | - } | |
350 | - // otherwise, add the arg to the arg strings | |
351 | - // and note the index if it was an option | |
352 | - else { | |
353 | - var pattern; | |
354 | - var optionTuple = self._parseOptional(argString); | |
355 | - if (!optionTuple) { | |
356 | - pattern = 'A'; | |
357 | - } | |
358 | - else { | |
359 | - optionStringIndices[argStringIndex] = optionTuple; | |
360 | - pattern = 'O'; | |
361 | - } | |
362 | - argStringPatternParts.push(pattern); | |
363 | - } | |
364 | - }); | |
365 | - var argStringsPattern = argStringPatternParts.join(''); | |
366 | - | |
367 | - var seenActions = []; | |
368 | - var seenNonDefaultActions = []; | |
369 | - | |
370 | - | |
371 | - function takeAction(action, argumentStrings, optionString) { | |
372 | - seenActions.push(action); | |
373 | - var argumentValues = self._getValues(action, argumentStrings); | |
374 | - | |
375 | - // error if this argument is not allowed with other previously | |
376 | - // seen arguments, assuming that actions that use the default | |
377 | - // value don't really count as "present" | |
378 | - if (argumentValues !== action.defaultValue) { | |
379 | - seenNonDefaultActions.push(action); | |
380 | - if (!!actionConflicts[actionHash(action)]) { | |
381 | - actionConflicts[actionHash(action)].forEach(function (actionConflict) { | |
382 | - if (seenNonDefaultActions.indexOf(actionConflict) >= 0) { | |
383 | - throw argumentErrorHelper( | |
384 | - action, | |
385 | - format('Not allowed with argument "%s".', actionConflict.getName()) | |
386 | - ); | |
387 | - } | |
388 | - }); | |
389 | - } | |
390 | - } | |
391 | - | |
392 | - if (argumentValues !== $$.SUPPRESS) { | |
393 | - action.call(self, namespace, argumentValues, optionString); | |
394 | - } | |
395 | - } | |
396 | - | |
397 | - function consumeOptional(startIndex) { | |
398 | - // get the optional identified at this index | |
399 | - var optionTuple = optionStringIndices[startIndex]; | |
400 | - var action = optionTuple[0]; | |
401 | - var optionString = optionTuple[1]; | |
402 | - var explicitArg = optionTuple[2]; | |
403 | - | |
404 | - // identify additional optionals in the same arg string | |
405 | - // (e.g. -xyz is the same as -x -y -z if no args are required) | |
406 | - var actionTuples = []; | |
407 | - | |
408 | - var args, argCount, start, stop; | |
409 | - | |
410 | - while (true) { | |
411 | - if (!action) { | |
412 | - extras.push(argStrings[startIndex]); | |
413 | - return startIndex + 1; | |
414 | - } | |
415 | - if (!!explicitArg) { | |
416 | - argCount = self._matchArgument(action, 'A'); | |
417 | - | |
418 | - // if the action is a single-dash option and takes no | |
419 | - // arguments, try to parse more single-dash options out | |
420 | - // of the tail of the option string | |
421 | - var chars = self.prefixChars; | |
422 | - if (argCount === 0 && chars.indexOf(optionString[1]) < 0) { | |
423 | - actionTuples.push([action, [], optionString]); | |
424 | - optionString = optionString[0] + explicitArg[0]; | |
425 | - var newExplicitArg = explicitArg.slice(1) || null; | |
426 | - var optionalsMap = self._optionStringActions; | |
427 | - | |
428 | - if (_.keys(optionalsMap).indexOf(optionString) >= 0) { | |
429 | - action = optionalsMap[optionString]; | |
430 | - explicitArg = newExplicitArg; | |
431 | - } | |
432 | - else { | |
433 | - var msg = 'ignored explicit argument %r'; | |
434 | - throw argumentErrorHelper(action, msg); | |
435 | - } | |
436 | - } | |
437 | - // if the action expect exactly one argument, we've | |
438 | - // successfully matched the option; exit the loop | |
439 | - else if (argCount === 1) { | |
440 | - stop = startIndex + 1; | |
441 | - args = [explicitArg]; | |
442 | - actionTuples.push([action, args, optionString]); | |
443 | - break; | |
444 | - } | |
445 | - // error if a double-dash option did not use the | |
446 | - // explicit argument | |
447 | - else { | |
448 | - var message = 'ignored explicit argument %r'; | |
449 | - throw argumentErrorHelper(action, _.str.sprintf(message, explicitArg)); | |
450 | - } | |
451 | - } | |
452 | - // if there is no explicit argument, try to match the | |
453 | - // optional's string arguments with the following strings | |
454 | - // if successful, exit the loop | |
455 | - else { | |
456 | - | |
457 | - start = startIndex + 1; | |
458 | - var selectedPatterns = argStringsPattern.substr(start); | |
459 | - | |
460 | - argCount = self._matchArgument(action, selectedPatterns); | |
461 | - stop = start + argCount; | |
462 | - | |
463 | - | |
464 | - args = argStrings.slice(start, stop); | |
465 | - | |
466 | - actionTuples.push([action, args, optionString]); | |
467 | - break; | |
468 | - } | |
469 | - | |
470 | - } | |
471 | - | |
472 | - // add the Optional to the list and return the index at which | |
473 | - // the Optional's string args stopped | |
474 | - if (actionTuples.length < 1) { | |
475 | - throw new Error('length should be > 0'); | |
476 | - } | |
477 | - for (var i = 0; i < actionTuples.length; i++) { | |
478 | - takeAction.apply(self, actionTuples[i]); | |
479 | - } | |
480 | - return stop; | |
481 | - } | |
482 | - | |
483 | - // the list of Positionals left to be parsed; this is modified | |
484 | - // by consume_positionals() | |
485 | - var positionals = self._getPositionalActions(); | |
486 | - | |
487 | - function consumePositionals(startIndex) { | |
488 | - // match as many Positionals as possible | |
489 | - var selectedPattern = argStringsPattern.substr(startIndex); | |
490 | - var argCounts = self._matchArgumentsPartial(positionals, selectedPattern); | |
491 | - | |
492 | - // slice off the appropriate arg strings for each Positional | |
493 | - // and add the Positional and its args to the list | |
494 | - _.zip(positionals, argCounts).forEach(function (item) { | |
495 | - var action = item[0]; | |
496 | - var argCount = item[1]; | |
497 | - if (argCount === undefined) { | |
498 | - return; | |
499 | - } | |
500 | - var args = argStrings.slice(startIndex, startIndex + argCount); | |
501 | - | |
502 | - startIndex += argCount; | |
503 | - takeAction(action, args); | |
504 | - }); | |
505 | - | |
506 | - // slice off the Positionals that we just parsed and return the | |
507 | - // index at which the Positionals' string args stopped | |
508 | - positionals = positionals.slice(argCounts.length); | |
509 | - return startIndex; | |
510 | - } | |
511 | - | |
512 | - // consume Positionals and Optionals alternately, until we have | |
513 | - // passed the last option string | |
514 | - var startIndex = 0; | |
515 | - var position; | |
516 | - | |
517 | - var maxOptionStringIndex = -1; | |
518 | - | |
519 | - Object.keys(optionStringIndices).forEach(function (position) { | |
520 | - maxOptionStringIndex = Math.max(maxOptionStringIndex, parseInt(position, 10)); | |
521 | - }); | |
522 | - | |
523 | - var positionalsEndIndex, nextOptionStringIndex; | |
524 | - | |
525 | - while (startIndex <= maxOptionStringIndex) { | |
526 | - // consume any Positionals preceding the next option | |
527 | - nextOptionStringIndex = null; | |
528 | - for (position in optionStringIndices) { | |
529 | - if (!optionStringIndices.hasOwnProperty(position)) { continue; } | |
530 | - | |
531 | - position = parseInt(position, 10); | |
532 | - if (position >= startIndex) { | |
533 | - if (nextOptionStringIndex !== null) { | |
534 | - nextOptionStringIndex = Math.min(nextOptionStringIndex, position); | |
535 | - } | |
536 | - else { | |
537 | - nextOptionStringIndex = position; | |
538 | - } | |
539 | - } | |
540 | - } | |
541 | - | |
542 | - if (startIndex !== nextOptionStringIndex) { | |
543 | - positionalsEndIndex = consumePositionals(startIndex); | |
544 | - // only try to parse the next optional if we didn't consume | |
545 | - // the option string during the positionals parsing | |
546 | - if (positionalsEndIndex > startIndex) { | |
547 | - startIndex = positionalsEndIndex; | |
548 | - continue; | |
549 | - } | |
550 | - else { | |
551 | - startIndex = positionalsEndIndex; | |
552 | - } | |
553 | - } | |
554 | - | |
555 | - // if we consumed all the positionals we could and we're not | |
556 | - // at the index of an option string, there were extra arguments | |
557 | - if (!optionStringIndices[startIndex]) { | |
558 | - var strings = argStrings.slice(startIndex, nextOptionStringIndex); | |
559 | - extras = extras.concat(strings); | |
560 | - startIndex = nextOptionStringIndex; | |
561 | - } | |
562 | - // consume the next optional and any arguments for it | |
563 | - startIndex = consumeOptional(startIndex); | |
564 | - } | |
565 | - | |
566 | - // consume any positionals following the last Optional | |
567 | - var stopIndex = consumePositionals(startIndex); | |
568 | - | |
569 | - // if we didn't consume all the argument strings, there were extras | |
570 | - extras = extras.concat(_.rest(argStrings, stopIndex)); | |
571 | - | |
572 | - // if we didn't use all the Positional objects, there were too few | |
573 | - // arg strings supplied. | |
574 | - if (positionals.length > 0) { | |
575 | - self.error('too few arguments'); | |
576 | - } | |
577 | - | |
578 | - // make sure all required actions were present | |
579 | - self._actions.forEach(function (action) { | |
580 | - if (action.required) { | |
581 | - if (_.indexOf(seenActions, action) < 0) { | |
582 | - self.error(format('Argument "%s" is required', action.getName())); | |
583 | - } | |
584 | - } | |
585 | - }); | |
586 | - | |
587 | - // make sure all required groups have one option present | |
588 | - var actionUsed = false; | |
589 | - self._mutuallyExclusiveGroups.forEach(function (group) { | |
590 | - if (group.required) { | |
591 | - actionUsed = _.any(group._groupActions, function (action) { | |
592 | - return _.contains(seenNonDefaultActions, action); | |
593 | - }); | |
594 | - | |
595 | - // if no actions were used, report the error | |
596 | - if (!actionUsed) { | |
597 | - var names = []; | |
598 | - group._groupActions.forEach(function (action) { | |
599 | - if (action.help !== $$.SUPPRESS) { | |
600 | - names.push(action.getName()); | |
601 | - } | |
602 | - }); | |
603 | - names = names.join(' '); | |
604 | - var msg = 'one of the arguments ' + names + ' is required'; | |
605 | - self.error(msg); | |
606 | - } | |
607 | - } | |
608 | - }); | |
609 | - | |
610 | - // return the updated namespace and the extra arguments | |
611 | - return [namespace, extras]; | |
612 | -}; | |
613 | - | |
614 | -ArgumentParser.prototype._readArgsFromFiles = function (argStrings) { | |
615 | - // expand arguments referencing files | |
616 | - var _this = this; | |
617 | - var fs = require('fs'); | |
618 | - var newArgStrings = []; | |
619 | - argStrings.forEach(function (argString) { | |
620 | - if (_this.fromfilePrefixChars.indexOf(argString[0]) < 0) { | |
621 | - // for regular arguments, just add them back into the list | |
622 | - newArgStrings.push(argString); | |
623 | - } else { | |
624 | - // replace arguments referencing files with the file content | |
625 | - try { | |
626 | - var argstrs = []; | |
627 | - var filename = argString.slice(1); | |
628 | - var content = fs.readFileSync(filename, 'utf8'); | |
629 | - content = content.trim().split('\n'); | |
630 | - content.forEach(function (argLine) { | |
631 | - _this.convertArgLineToArgs(argLine).forEach(function (arg) { | |
632 | - argstrs.push(arg); | |
633 | - }); | |
634 | - argstrs = _this._readArgsFromFiles(argstrs); | |
635 | - }); | |
636 | - newArgStrings.push.apply(newArgStrings, argstrs); | |
637 | - } catch (error) { | |
638 | - return _this.error(error.message); | |
639 | - } | |
640 | - } | |
641 | - }); | |
642 | - return newArgStrings; | |
643 | -}; | |
644 | - | |
645 | -ArgumentParser.prototype.convertArgLineToArgs = function (argLine) { | |
646 | - return [argLine]; | |
647 | -}; | |
648 | - | |
649 | -ArgumentParser.prototype._matchArgument = function (action, regexpArgStrings) { | |
650 | - | |
651 | - // match the pattern for this action to the arg strings | |
652 | - var regexpNargs = new RegExp('^' + this._getNargsPattern(action)); | |
653 | - var matches = regexpArgStrings.match(regexpNargs); | |
654 | - var message; | |
655 | - | |
656 | - // throw an exception if we weren't able to find a match | |
657 | - if (!matches) { | |
658 | - switch (action.nargs) { | |
659 | - case undefined: | |
660 | - case null: | |
661 | - message = 'Expected one argument.'; | |
662 | - break; | |
663 | - case $$.OPTIONAL: | |
664 | - message = 'Expected at most one argument.'; | |
665 | - break; | |
666 | - case $$.ONE_OR_MORE: | |
667 | - message = 'Expected at least one argument.'; | |
668 | - break; | |
669 | - default: | |
670 | - message = 'Expected %s argument(s)'; | |
671 | - } | |
672 | - | |
673 | - throw argumentErrorHelper( | |
674 | - action, | |
675 | - format(message, action.nargs) | |
676 | - ); | |
677 | - } | |
678 | - // return the number of arguments matched | |
679 | - return matches[1].length; | |
680 | -}; | |
681 | - | |
682 | -ArgumentParser.prototype._matchArgumentsPartial = function (actions, regexpArgStrings) { | |
683 | - // progressively shorten the actions list by slicing off the | |
684 | - // final actions until we find a match | |
685 | - var self = this; | |
686 | - var result = []; | |
687 | - var actionSlice, pattern, matches; | |
688 | - var i, j; | |
689 | - | |
690 | - var getLength = function (string) { | |
691 | - return string.length; | |
692 | - }; | |
693 | - | |
694 | - for (i = actions.length; i > 0; i--) { | |
695 | - pattern = ''; | |
696 | - actionSlice = actions.slice(0, i); | |
697 | - for (j = 0; j < actionSlice.length; j++) { | |
698 | - pattern += self._getNargsPattern(actionSlice[j]); | |
699 | - } | |
700 | - | |
701 | - pattern = new RegExp('^' + pattern); | |
702 | - matches = regexpArgStrings.match(pattern); | |
703 | - | |
704 | - if (matches && matches.length > 0) { | |
705 | - // need only groups | |
706 | - matches = matches.splice(1); | |
707 | - result = result.concat(matches.map(getLength)); | |
708 | - break; | |
709 | - } | |
710 | - } | |
711 | - | |
712 | - // return the list of arg string counts | |
713 | - return result; | |
714 | -}; | |
715 | - | |
716 | -ArgumentParser.prototype._parseOptional = function (argString) { | |
717 | - var action, optionString, argExplicit, optionTuples; | |
718 | - | |
719 | - // if it's an empty string, it was meant to be a positional | |
720 | - if (!argString) { | |
721 | - return null; | |
722 | - } | |
723 | - | |
724 | - // if it doesn't start with a prefix, it was meant to be positional | |
725 | - if (this.prefixChars.indexOf(argString[0]) < 0) { | |
726 | - return null; | |
727 | - } | |
728 | - | |
729 | - // if the option string is present in the parser, return the action | |
730 | - if (!!this._optionStringActions[argString]) { | |
731 | - return [this._optionStringActions[argString], argString, null]; | |
732 | - } | |
733 | - | |
734 | - // if it's just a single character, it was meant to be positional | |
735 | - if (argString.length === 1) { | |
736 | - return null; | |
737 | - } | |
738 | - | |
739 | - // if the option string before the "=" is present, return the action | |
740 | - if (argString.indexOf('=') >= 0) { | |
741 | - var argStringSplit = argString.split('='); | |
742 | - optionString = argStringSplit[0]; | |
743 | - argExplicit = argStringSplit[1]; | |
744 | - | |
745 | - if (!!this._optionStringActions[optionString]) { | |
746 | - action = this._optionStringActions[optionString]; | |
747 | - return [action, optionString, argExplicit]; | |
748 | - } | |
749 | - } | |
750 | - | |
751 | - // search through all possible prefixes of the option string | |
752 | - // and all actions in the parser for possible interpretations | |
753 | - optionTuples = this._getOptionTuples(argString); | |
754 | - | |
755 | - // if multiple actions match, the option string was ambiguous | |
756 | - if (optionTuples.length > 1) { | |
757 | - var optionStrings = optionTuples.map(function (optionTuple) { | |
758 | - return optionTuple[1]; | |
759 | - }); | |
760 | - this.error(format( | |
761 | - 'Ambiguous option: "%s" could match %s.', | |
762 | - argString, optionStrings.join(', ') | |
763 | - )); | |
764 | - // if exactly one action matched, this segmentation is good, | |
765 | - // so return the parsed action | |
766 | - } else if (optionTuples.length === 1) { | |
767 | - return optionTuples[0]; | |
768 | - } | |
769 | - | |
770 | - // if it was not found as an option, but it looks like a negative | |
771 | - // number, it was meant to be positional | |
772 | - // unless there are negative-number-like options | |
773 | - if (argString.match(this._regexpNegativeNumber)) { | |
774 | - if (!_.any(this._hasNegativeNumberOptionals)) { | |
775 | - return null; | |
776 | - } | |
777 | - } | |
778 | - // if it contains a space, it was meant to be a positional | |
779 | - if (argString.search(' ') >= 0) { | |
780 | - return null; | |
781 | - } | |
782 | - | |
783 | - // it was meant to be an optional but there is no such option | |
784 | - // in this parser (though it might be a valid option in a subparser) | |
785 | - return [null, argString, null]; | |
786 | -}; | |
787 | - | |
788 | -ArgumentParser.prototype._getOptionTuples = function (optionString) { | |
789 | - var result = []; | |
790 | - var chars = this.prefixChars; | |
791 | - var optionPrefix; | |
792 | - var argExplicit; | |
793 | - var action; | |
794 | - var actionOptionString; | |
795 | - | |
796 | - // option strings starting with two prefix characters are only split at | |
797 | - // the '=' | |
798 | - if (chars.indexOf(optionString[0]) >= 0 && chars.indexOf(optionString[1]) >= 0) { | |
799 | - if (optionString.indexOf('=') >= 0) { | |
800 | - var optionStringSplit = optionString.split('=', 1); | |
801 | - | |
802 | - optionPrefix = optionStringSplit[0]; | |
803 | - argExplicit = optionStringSplit[1]; | |
804 | - } else { | |
805 | - optionPrefix = optionString; | |
806 | - argExplicit = null; | |
807 | - } | |
808 | - | |
809 | - for (actionOptionString in this._optionStringActions) { | |
810 | - if (actionOptionString.substr(0, optionPrefix.length) === optionPrefix) { | |
811 | - action = this._optionStringActions[actionOptionString]; | |
812 | - result.push([action, actionOptionString, argExplicit]); | |
813 | - } | |
814 | - } | |
815 | - | |
816 | - // single character options can be concatenated with their arguments | |
817 | - // but multiple character options always have to have their argument | |
818 | - // separate | |
819 | - } else if (chars.indexOf(optionString[0]) >= 0 && chars.indexOf(optionString[1]) < 0) { | |
820 | - optionPrefix = optionString; | |
821 | - argExplicit = null; | |
822 | - var optionPrefixShort = optionString.substr(0, 2); | |
823 | - var argExplicitShort = optionString.substr(2); | |
824 | - | |
825 | - for (actionOptionString in this._optionStringActions) { | |
826 | - action = this._optionStringActions[actionOptionString]; | |
827 | - if (actionOptionString === optionPrefixShort) { | |
828 | - result.push([action, actionOptionString, argExplicitShort]); | |
829 | - } else if (actionOptionString.substr(0, optionPrefix.length) === optionPrefix) { | |
830 | - result.push([action, actionOptionString, argExplicit]); | |
831 | - } | |
832 | - } | |
833 | - | |
834 | - // shouldn't ever get here | |
835 | - } else { | |
836 | - throw new Error(format('Unexpected option string: %s.', optionString)); | |
837 | - } | |
838 | - // return the collected option tuples | |
839 | - return result; | |
840 | -}; | |
841 | - | |
842 | -ArgumentParser.prototype._getNargsPattern = function (action) { | |
843 | - // in all examples below, we have to allow for '--' args | |
844 | - // which are represented as '-' in the pattern | |
845 | - var regexpNargs; | |
846 | - | |
847 | - switch (action.nargs) { | |
848 | - // the default (null) is assumed to be a single argument | |
849 | - case undefined: | |
850 | - case null: | |
851 | - regexpNargs = '(-*A-*)'; | |
852 | - break; | |
853 | - // allow zero or more arguments | |
854 | - case $$.OPTIONAL: | |
855 | - regexpNargs = '(-*A?-*)'; | |
856 | - break; | |
857 | - // allow zero or more arguments | |
858 | - case $$.ZERO_OR_MORE: | |
859 | - regexpNargs = '(-*[A-]*)'; | |
860 | - break; | |
861 | - // allow one or more arguments | |
862 | - case $$.ONE_OR_MORE: | |
863 | - regexpNargs = '(-*A[A-]*)'; | |
864 | - break; | |
865 | - // allow any number of options or arguments | |
866 | - case $$.REMAINDER: | |
867 | - regexpNargs = '([-AO]*)'; | |
868 | - break; | |
869 | - // allow one argument followed by any number of options or arguments | |
870 | - case $$.PARSER: | |
871 | - regexpNargs = '(-*A[-AO]*)'; | |
872 | - break; | |
873 | - // all others should be integers | |
874 | - default: | |
875 | - regexpNargs = '(-*' + _.str.repeat('-*A', action.nargs) + '-*)'; | |
876 | - } | |
877 | - | |
878 | - // if this is an optional action, -- is not allowed | |
879 | - if (action.isOptional()) { | |
880 | - regexpNargs = regexpNargs.replace(/-\*/g, ''); | |
881 | - regexpNargs = regexpNargs.replace(/-/g, ''); | |
882 | - } | |
883 | - | |
884 | - // return the pattern | |
885 | - return regexpNargs; | |
886 | -}; | |
887 | - | |
888 | -// | |
889 | -// Value conversion methods | |
890 | -// | |
891 | - | |
892 | -ArgumentParser.prototype._getValues = function (action, argStrings) { | |
893 | - var self = this; | |
894 | - | |
895 | - // for everything but PARSER args, strip out '--' | |
896 | - if (action.nargs !== $$.PARSER && action.nargs !== $$.REMAINDER) { | |
897 | - argStrings = argStrings.filter(function (arrayElement) { | |
898 | - return arrayElement !== '--'; | |
899 | - }); | |
900 | - } | |
901 | - | |
902 | - var value, argString; | |
903 | - | |
904 | - // optional argument produces a default when not present | |
905 | - if (argStrings.length === 0 && action.nargs === $$.OPTIONAL) { | |
906 | - | |
907 | - value = (action.isOptional()) ? action.constant: action.defaultValue; | |
908 | - | |
909 | - if (typeof(value) === 'string') { | |
910 | - value = this._getValue(action, value); | |
911 | - this._checkValue(action, value); | |
912 | - } | |
913 | - | |
914 | - // when nargs='*' on a positional, if there were no command-line | |
915 | - // args, use the default if it is anything other than None | |
916 | - } else if (argStrings.length === 0 && action.nargs === $$.ZERO_OR_MORE && | |
917 | - action.optionStrings.length === 0) { | |
918 | - | |
919 | - value = (action.defaultValue || argStrings); | |
920 | - this._checkValue(action, value); | |
921 | - | |
922 | - // single argument or optional argument produces a single value | |
923 | - } else if (argStrings.length === 1 && | |
924 | - (!action.nargs || action.nargs === $$.OPTIONAL)) { | |
925 | - | |
926 | - argString = argStrings[0]; | |
927 | - value = this._getValue(action, argString); | |
928 | - this._checkValue(action, value); | |
929 | - | |
930 | - // REMAINDER arguments convert all values, checking none | |
931 | - } else if (action.nargs === $$.REMAINDER) { | |
932 | - value = argStrings.map(function (v) { | |
933 | - return self._getValue(action, v); | |
934 | - }); | |
935 | - | |
936 | - // PARSER arguments convert all values, but check only the first | |
937 | - } else if (action.nargs === $$.PARSER) { | |
938 | - value = argStrings.map(function (v) { | |
939 | - return self._getValue(action, v); | |
940 | - }); | |
941 | - this._checkValue(action, value[0]); | |
942 | - | |
943 | - // all other types of nargs produce a list | |
944 | - } else { | |
945 | - value = argStrings.map(function (v) { | |
946 | - return self._getValue(action, v); | |
947 | - }); | |
948 | - value.forEach(function (v) { | |
949 | - self._checkValue(action, v); | |
950 | - }); | |
951 | - } | |
952 | - | |
953 | - // return the converted value | |
954 | - return value; | |
955 | -}; | |
956 | - | |
957 | -ArgumentParser.prototype._getValue = function (action, argString) { | |
958 | - var result; | |
959 | - | |
960 | - var typeFunction = this._registryGet('type', action.type, action.type); | |
961 | - if (!_.isFunction(typeFunction)) { | |
962 | - var message = format('%s is not callable', typeFunction); | |
963 | - throw argumentErrorHelper(action, message); | |
964 | - } | |
965 | - | |
966 | - // convert the value to the appropriate type | |
967 | - try { | |
968 | - result = typeFunction(argString); | |
969 | - | |
970 | - // ArgumentTypeErrors indicate errors | |
971 | - // If action.type is not a registered string, it is a function | |
972 | - // Try to deduce its name for inclusion in the error message | |
973 | - // Failing that, include the error message it raised. | |
974 | - } catch (e) { | |
975 | - var name = null; | |
976 | - if (_.isString(action.type)) { | |
977 | - name = action.type; | |
978 | - } else { | |
979 | - name = action.type.name || action.type.displayName || '<function>'; | |
980 | - } | |
981 | - var msg = format('Invalid %s value: %s', name, argString); | |
982 | - if (name === '<function>') {msg += '\n' + e.message; } | |
983 | - throw argumentErrorHelper(action, msg); | |
984 | - } | |
985 | - // return the converted value | |
986 | - return result; | |
987 | -}; | |
988 | - | |
989 | -ArgumentParser.prototype._checkValue = function (action, value) { | |
990 | - // converted value must be one of the choices (if specified) | |
991 | - var choices = action.choices; | |
992 | - if (!!choices) { | |
993 | - // choise for argument can by array or string | |
994 | - if ((_.isString(choices) || _.isArray(choices)) && | |
995 | - choices.indexOf(value) !== -1) { | |
996 | - return; | |
997 | - } | |
998 | - // choise for subparsers can by only hash | |
999 | - if (_.isObject(choices) && !_.isArray(choices) && choices[value]) { | |
1000 | - return; | |
1001 | - } | |
1002 | - | |
1003 | - if (_.isString(choices)) { | |
1004 | - choices = choices.split('').join(', '); | |
1005 | - } | |
1006 | - else if (_.isArray(choices)) { | |
1007 | - choices = choices.join(', '); | |
1008 | - } | |
1009 | - else { | |
1010 | - choices = _.keys(choices).join(', '); | |
1011 | - } | |
1012 | - var message = format('Invalid choice: %s (choose from [%s])', value, choices); | |
1013 | - throw argumentErrorHelper(action, message); | |
1014 | - } | |
1015 | -}; | |
1016 | - | |
1017 | -// | |
1018 | -// Help formatting methods | |
1019 | -// | |
1020 | - | |
1021 | -/** | |
1022 | - * ArgumentParser#formatUsage -> string | |
1023 | - * | |
1024 | - * Return usage string | |
1025 | - * | |
1026 | - * See also [original guide][1] | |
1027 | - * | |
1028 | - * [1]:http://docs.python.org/dev/library/argparse.html#printing-help | |
1029 | - **/ | |
1030 | -ArgumentParser.prototype.formatUsage = function () { | |
1031 | - var formatter = this._getFormatter(); | |
1032 | - formatter.addUsage(this.usage, this._actions, this._mutuallyExclusiveGroups); | |
1033 | - return formatter.formatHelp(); | |
1034 | -}; | |
1035 | - | |
1036 | -/** | |
1037 | - * ArgumentParser#formatHelp -> string | |
1038 | - * | |
1039 | - * Return help | |
1040 | - * | |
1041 | - * See also [original guide][1] | |
1042 | - * | |
1043 | - * [1]:http://docs.python.org/dev/library/argparse.html#printing-help | |
1044 | - **/ | |
1045 | -ArgumentParser.prototype.formatHelp = function () { | |
1046 | - var formatter = this._getFormatter(); | |
1047 | - | |
1048 | - // usage | |
1049 | - formatter.addUsage(this.usage, this._actions, this._mutuallyExclusiveGroups); | |
1050 | - | |
1051 | - // description | |
1052 | - formatter.addText(this.description); | |
1053 | - | |
1054 | - // positionals, optionals and user-defined groups | |
1055 | - this._actionGroups.forEach(function (actionGroup) { | |
1056 | - formatter.startSection(actionGroup.title); | |
1057 | - formatter.addText(actionGroup.description); | |
1058 | - formatter.addArguments(actionGroup._groupActions); | |
1059 | - formatter.endSection(); | |
1060 | - }); | |
1061 | - | |
1062 | - // epilog | |
1063 | - formatter.addText(this.epilog); | |
1064 | - | |
1065 | - // determine help from format above | |
1066 | - return formatter.formatHelp(); | |
1067 | -}; | |
1068 | - | |
1069 | -ArgumentParser.prototype._getFormatter = function () { | |
1070 | - var FormatterClass = this.formatterClass; | |
1071 | - var formatter = new FormatterClass({prog: this.prog}); | |
1072 | - return formatter; | |
1073 | -}; | |
1074 | - | |
1075 | -// | |
1076 | -// Print functions | |
1077 | -// | |
1078 | - | |
1079 | -/** | |
1080 | - * ArgumentParser#printUsage() -> Void | |
1081 | - * | |
1082 | - * Print usage | |
1083 | - * | |
1084 | - * See also [original guide][1] | |
1085 | - * | |
1086 | - * [1]:http://docs.python.org/dev/library/argparse.html#printing-help | |
1087 | - **/ | |
1088 | -ArgumentParser.prototype.printUsage = function () { | |
1089 | - this._printMessage(this.formatUsage()); | |
1090 | -}; | |
1091 | - | |
1092 | -/** | |
1093 | - * ArgumentParser#printHelp() -> Void | |
1094 | - * | |
1095 | - * Print help | |
1096 | - * | |
1097 | - * See also [original guide][1] | |
1098 | - * | |
1099 | - * [1]:http://docs.python.org/dev/library/argparse.html#printing-help | |
1100 | - **/ | |
1101 | -ArgumentParser.prototype.printHelp = function () { | |
1102 | - this._printMessage(this.formatHelp()); | |
1103 | -}; | |
1104 | - | |
1105 | -ArgumentParser.prototype._printMessage = function (message, stream) { | |
1106 | - if (!stream) { | |
1107 | - stream = process.stdout; | |
1108 | - } | |
1109 | - if (message) { | |
1110 | - stream.write('' + message); | |
1111 | - } | |
1112 | -}; | |
1113 | - | |
1114 | -// | |
1115 | -// Exit functions | |
1116 | -// | |
1117 | - | |
1118 | -/** | |
1119 | - * ArgumentParser#exit(status=0, message) -> Void | |
1120 | - * - status (int): exit status | |
1121 | - * - message (string): message | |
1122 | - * | |
1123 | - * Print message in stderr/stdout and exit program | |
1124 | - **/ | |
1125 | -ArgumentParser.prototype.exit = function (status, message) { | |
1126 | - if (!!message) { | |
1127 | - if (status === 0) { | |
1128 | - this._printMessage(message); | |
1129 | - } | |
1130 | - else { | |
1131 | - this._printMessage(message, process.stderr); | |
1132 | - } | |
1133 | - } | |
1134 | - | |
1135 | - process.exit(status); | |
1136 | -}; | |
1137 | - | |
1138 | -/** | |
1139 | - * ArgumentParser#error(message) -> Void | |
1140 | - * - err (Error|string): message | |
1141 | - * | |
1142 | - * Error method Prints a usage message incorporating the message to stderr and | |
1143 | - * exits. If you override this in a subclass, | |
1144 | - * it should not return -- it should | |
1145 | - * either exit or throw an exception. | |
1146 | - * | |
1147 | - **/ | |
1148 | -ArgumentParser.prototype.error = function (err) { | |
1149 | - var message; | |
1150 | - if (err instanceof Error) { | |
1151 | - if (this.debug === true) { | |
1152 | - throw err; | |
1153 | - } | |
1154 | - message = err.message; | |
1155 | - } | |
1156 | - else { | |
1157 | - message = err; | |
1158 | - } | |
1159 | - var msg = format('%s: error: %s', this.prog, message) + $$.EOL; | |
1160 | - | |
1161 | - if (this.debug === true) { | |
1162 | - throw new Error(msg); | |
1163 | - } | |
1164 | - | |
1165 | - this.printUsage(process.stderr); | |
1166 | - | |
1167 | - return this.exit(2, msg); | |
1168 | -}; |
images/node_modules/argparse/lib/const.js deleted
100644 → 0
1 | -// | |
2 | -// Constants | |
3 | -// | |
4 | -module.exports.EOL = '\n'; | |
5 | - | |
6 | -module.exports.SUPPRESS = '==SUPPRESS=='; | |
7 | - | |
8 | -module.exports.OPTIONAL = '?'; | |
9 | - | |
10 | -module.exports.ZERO_OR_MORE = '*'; | |
11 | - | |
12 | -module.exports.ONE_OR_MORE = '+'; | |
13 | - | |
14 | -module.exports.PARSER = 'A...'; | |
15 | - | |
16 | -module.exports.REMAINDER = '...'; | |
17 | - | |
18 | -module.exports._UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args'; |
images/node_modules/argparse/lib/help/added_formatters.js deleted
100644 → 0
1 | -'use strict'; | |
2 | - | |
3 | -var util = require('util'); | |
4 | -var _ = require('underscore'); | |
5 | -_.str = require('underscore.string'); | |
6 | - | |
7 | -// Constants | |
8 | -var $$ = require('../const'); | |
9 | - | |
10 | -var HelpFormatter = require('./formatter.js'); | |
11 | - | |
12 | -/** | |
13 | - * new RawDescriptionHelpFormatter(options) | |
14 | - * new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...}) | |
15 | - * | |
16 | - * Help message formatter which adds default values to argument help. | |
17 | - * | |
18 | - * Only the name of this class is considered a public API. All the methods | |
19 | - * provided by the class are considered an implementation detail. | |
20 | - **/ | |
21 | - | |
22 | -var ArgumentDefaultsHelpFormatter = function ArgumentDefaultsHelpFormatter(options) { | |
23 | - HelpFormatter.call(this, options); | |
24 | -}; | |
25 | - | |
26 | -util.inherits(ArgumentDefaultsHelpFormatter, HelpFormatter); | |
27 | - | |
28 | -ArgumentDefaultsHelpFormatter.prototype._getHelpString = function (action) { | |
29 | - var help = action.help; | |
30 | - if (action.help.indexOf('%(defaultValue)s') === -1) { | |
31 | - if (action.defaultValue !== $$.SUPPRESS) { | |
32 | - var defaulting_nargs = [$$.OPTIONAL, $$.ZERO_OR_MORE]; | |
33 | - if (action.isOptional() || (defaulting_nargs.indexOf(action.nargs) >= 0)) { | |
34 | - help += ' (default: %(defaultValue)s)'; | |
35 | - } | |
36 | - } | |
37 | - } | |
38 | - return help; | |
39 | -}; | |
40 | - | |
41 | -module.exports.ArgumentDefaultsHelpFormatter = ArgumentDefaultsHelpFormatter; | |
42 | - | |
43 | -/** | |
44 | - * new RawDescriptionHelpFormatter(options) | |
45 | - * new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...}) | |
46 | - * | |
47 | - * Help message formatter which retains any formatting in descriptions. | |
48 | - * | |
49 | - * Only the name of this class is considered a public API. All the methods | |
50 | - * provided by the class are considered an implementation detail. | |
51 | - **/ | |
52 | - | |
53 | -var RawDescriptionHelpFormatter = function RawDescriptionHelpFormatter(options) { | |
54 | - HelpFormatter.call(this, options); | |
55 | -}; | |
56 | - | |
57 | -util.inherits(RawDescriptionHelpFormatter, HelpFormatter); | |
58 | - | |
59 | -RawDescriptionHelpFormatter.prototype._fillText = function (text, width, indent) { | |
60 | - var lines = text.split('\n'); | |
61 | - lines = lines.map(function (line) { | |
62 | - return _.str.rtrim(indent + line); | |
63 | - }); | |
64 | - return lines.join('\n'); | |
65 | -}; | |
66 | -module.exports.RawDescriptionHelpFormatter = RawDescriptionHelpFormatter; | |
67 | - | |
68 | -/** | |
69 | - * new RawTextHelpFormatter(options) | |
70 | - * new ArgumentParser({formatterClass: argparse.RawTextHelpFormatter, ...}) | |
71 | - * | |
72 | - * Help message formatter which retains formatting of all help text. | |
73 | - * | |
74 | - * Only the name of this class is considered a public API. All the methods | |
75 | - * provided by the class are considered an implementation detail. | |
76 | - **/ | |
77 | - | |
78 | -var RawTextHelpFormatter = function RawTextHelpFormatter(options) { | |
79 | - RawDescriptionHelpFormatter.call(this, options); | |
80 | -}; | |
81 | - | |
82 | -util.inherits(RawTextHelpFormatter, RawDescriptionHelpFormatter); | |
83 | - | |
84 | -RawTextHelpFormatter.prototype._splitLines = function (text) { | |
85 | - return text.split('\n'); | |
86 | -}; | |
87 | - | |
88 | -module.exports.RawTextHelpFormatter = RawTextHelpFormatter; |