poe-code 13.0.0 → 13.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +26 -5
  2. package/dist/index.js +96 -7
  3. package/dist/index.js.map +4 -4
  4. package/dist/metafile.json +1 -1
  5. package/node_modules/esprima/LICENSE.BSD +21 -0
  6. package/node_modules/esprima/README.md +46 -0
  7. package/node_modules/esprima/bin/esparse.js +139 -0
  8. package/node_modules/esprima/bin/esvalidate.js +236 -0
  9. package/node_modules/esprima/dist/esprima.js +6709 -0
  10. package/node_modules/esprima/package.json +112 -0
  11. package/node_modules/extend-shallow/LICENSE +21 -0
  12. package/node_modules/extend-shallow/README.md +61 -0
  13. package/node_modules/extend-shallow/index.js +33 -0
  14. package/node_modules/extend-shallow/package.json +56 -0
  15. package/node_modules/gray-matter/LICENSE +21 -0
  16. package/node_modules/gray-matter/README.md +565 -0
  17. package/node_modules/gray-matter/gray-matter.d.ts +114 -0
  18. package/node_modules/gray-matter/index.js +228 -0
  19. package/node_modules/gray-matter/lib/defaults.js +18 -0
  20. package/node_modules/gray-matter/lib/engine.js +30 -0
  21. package/node_modules/gray-matter/lib/engines.js +54 -0
  22. package/node_modules/gray-matter/lib/excerpt.js +32 -0
  23. package/node_modules/gray-matter/lib/parse.js +13 -0
  24. package/node_modules/gray-matter/lib/stringify.js +56 -0
  25. package/node_modules/gray-matter/lib/to-file.js +43 -0
  26. package/node_modules/gray-matter/lib/utils.js +66 -0
  27. package/node_modules/gray-matter/node_modules/argparse/LICENSE +21 -0
  28. package/node_modules/gray-matter/node_modules/argparse/README.md +257 -0
  29. package/node_modules/gray-matter/node_modules/argparse/index.js +3 -0
  30. package/node_modules/gray-matter/node_modules/argparse/lib/action/append/constant.js +47 -0
  31. package/node_modules/gray-matter/node_modules/argparse/lib/action/append.js +53 -0
  32. package/node_modules/gray-matter/node_modules/argparse/lib/action/count.js +40 -0
  33. package/node_modules/gray-matter/node_modules/argparse/lib/action/help.js +47 -0
  34. package/node_modules/gray-matter/node_modules/argparse/lib/action/store/constant.js +43 -0
  35. package/node_modules/gray-matter/node_modules/argparse/lib/action/store/false.js +27 -0
  36. package/node_modules/gray-matter/node_modules/argparse/lib/action/store/true.js +26 -0
  37. package/node_modules/gray-matter/node_modules/argparse/lib/action/store.js +50 -0
  38. package/node_modules/gray-matter/node_modules/argparse/lib/action/subparsers.js +149 -0
  39. package/node_modules/gray-matter/node_modules/argparse/lib/action/version.js +47 -0
  40. package/node_modules/gray-matter/node_modules/argparse/lib/action.js +146 -0
  41. package/node_modules/gray-matter/node_modules/argparse/lib/action_container.js +482 -0
  42. package/node_modules/gray-matter/node_modules/argparse/lib/argparse.js +14 -0
  43. package/node_modules/gray-matter/node_modules/argparse/lib/argument/error.js +50 -0
  44. package/node_modules/gray-matter/node_modules/argparse/lib/argument/exclusive.js +54 -0
  45. package/node_modules/gray-matter/node_modules/argparse/lib/argument/group.js +75 -0
  46. package/node_modules/gray-matter/node_modules/argparse/lib/argument_parser.js +1161 -0
  47. package/node_modules/gray-matter/node_modules/argparse/lib/const.js +21 -0
  48. package/node_modules/gray-matter/node_modules/argparse/lib/help/added_formatters.js +87 -0
  49. package/node_modules/gray-matter/node_modules/argparse/lib/help/formatter.js +795 -0
  50. package/node_modules/gray-matter/node_modules/argparse/lib/namespace.js +76 -0
  51. package/node_modules/gray-matter/node_modules/argparse/lib/utils.js +57 -0
  52. package/node_modules/gray-matter/node_modules/argparse/package.json +34 -0
  53. package/node_modules/gray-matter/node_modules/js-yaml/LICENSE +21 -0
  54. package/node_modules/gray-matter/node_modules/js-yaml/README.md +302 -0
  55. package/node_modules/gray-matter/node_modules/js-yaml/bin/js-yaml.js +132 -0
  56. package/node_modules/gray-matter/node_modules/js-yaml/dist/js-yaml.js +4011 -0
  57. package/node_modules/gray-matter/node_modules/js-yaml/dist/js-yaml.min.js +1 -0
  58. package/node_modules/gray-matter/node_modules/js-yaml/index.js +7 -0
  59. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/common.js +59 -0
  60. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/dumper.js +850 -0
  61. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/exception.js +43 -0
  62. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/loader.js +1666 -0
  63. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/mark.js +76 -0
  64. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
  65. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
  66. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
  67. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
  68. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
  69. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema.js +108 -0
  70. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/binary.js +138 -0
  71. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/bool.js +35 -0
  72. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/float.js +116 -0
  73. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/int.js +173 -0
  74. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/function.js +93 -0
  75. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +60 -0
  76. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +28 -0
  77. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
  78. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
  79. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/null.js +34 -0
  80. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/omap.js +44 -0
  81. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/pairs.js +53 -0
  82. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
  83. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/set.js +29 -0
  84. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
  85. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +88 -0
  86. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
  87. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml.js +39 -0
  88. package/node_modules/gray-matter/node_modules/js-yaml/package.json +52 -0
  89. package/node_modules/gray-matter/package.json +127 -0
  90. package/node_modules/is-extendable/LICENSE +21 -0
  91. package/node_modules/is-extendable/README.md +72 -0
  92. package/node_modules/is-extendable/index.js +13 -0
  93. package/node_modules/is-extendable/package.json +51 -0
  94. package/node_modules/kind-of/LICENSE +21 -0
  95. package/node_modules/kind-of/README.md +367 -0
  96. package/node_modules/kind-of/index.js +129 -0
  97. package/node_modules/kind-of/package.json +88 -0
  98. package/node_modules/section-matter/LICENSE +21 -0
  99. package/node_modules/section-matter/README.md +236 -0
  100. package/node_modules/section-matter/index.js +136 -0
  101. package/node_modules/section-matter/package.json +55 -0
  102. package/node_modules/sprintf-js/.npmignore +1 -0
  103. package/node_modules/sprintf-js/LICENSE +24 -0
  104. package/node_modules/sprintf-js/README.md +88 -0
  105. package/node_modules/sprintf-js/bower.json +14 -0
  106. package/node_modules/sprintf-js/demo/angular.html +20 -0
  107. package/node_modules/sprintf-js/dist/angular-sprintf.min.js +4 -0
  108. package/node_modules/sprintf-js/dist/angular-sprintf.min.js.map +1 -0
  109. package/node_modules/sprintf-js/dist/angular-sprintf.min.map +1 -0
  110. package/node_modules/sprintf-js/dist/sprintf.min.js +4 -0
  111. package/node_modules/sprintf-js/dist/sprintf.min.js.map +1 -0
  112. package/node_modules/sprintf-js/dist/sprintf.min.map +1 -0
  113. package/node_modules/sprintf-js/gruntfile.js +36 -0
  114. package/node_modules/sprintf-js/package.json +22 -0
  115. package/node_modules/sprintf-js/src/angular-sprintf.js +18 -0
  116. package/node_modules/sprintf-js/src/sprintf.js +208 -0
  117. package/node_modules/sprintf-js/test/test.js +82 -0
  118. package/node_modules/strip-bom-string/LICENSE +21 -0
  119. package/node_modules/strip-bom-string/README.md +66 -0
  120. package/node_modules/strip-bom-string/index.js +15 -0
  121. package/node_modules/strip-bom-string/package.json +60 -0
  122. package/package.json +6 -3
  123. package/packages/safe-js/dist/chunks/{chunk-EL23VF23.js → chunk-JP474LP7.js} +2 -2
  124. package/packages/safe-js/dist/chunks/{chunk-DALBPQDZ.js → chunk-RIQRHKCB.js} +82 -4
  125. package/packages/safe-js/dist/chunks/{chunk-DALBPQDZ.js.map → chunk-RIQRHKCB.js.map} +4 -4
  126. package/packages/safe-js/dist/cli.js +2 -2
  127. package/packages/safe-js/dist/core.js +1 -1
  128. package/packages/safe-js/dist/index.js +2 -2
  129. package/packages/safe-js/dist/interp/globals/object-array.js +2 -7
  130. package/packages/safe-js/dist/interp/interpreter.js +1 -0
  131. package/packages/safe-js/dist/interp/string-coercion.d.ts +3 -0
  132. package/packages/safe-js/dist/interp/string-coercion.js +89 -0
  133. package/packages/safe-js/dist/interp/values.d.ts +1 -0
  134. /package/packages/safe-js/dist/chunks/{chunk-EL23VF23.js.map → chunk-JP474LP7.js.map} +0 -0
@@ -0,0 +1,257 @@
1
+ argparse
2
+ ========
3
+
4
+ [![Build Status](https://secure.travis-ci.org/nodeca/argparse.svg?branch=master)](http://travis-ci.org/nodeca/argparse)
5
+ [![NPM version](https://img.shields.io/npm/v/argparse.svg)](https://www.npmjs.org/package/argparse)
6
+
7
+ CLI arguments parser for node.js. Javascript port of python's
8
+ [argparse](http://docs.python.org/dev/library/argparse.html) module
9
+ (original version 3.2). That's a full port, except some very rare options,
10
+ recorded in issue tracker.
11
+
12
+ **NB. Difference with original.**
13
+
14
+ - Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
15
+ - Use `defaultValue` instead of `default`.
16
+ - Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
17
+ similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
18
+ (aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
19
+ `SUPPRESS`.
20
+
21
+
22
+ Example
23
+ =======
24
+
25
+ test.js file:
26
+
27
+ ```javascript
28
+ #!/usr/bin/env node
29
+ 'use strict';
30
+
31
+ var ArgumentParser = require('../lib/argparse').ArgumentParser;
32
+ var parser = new ArgumentParser({
33
+ version: '0.0.1',
34
+ addHelp:true,
35
+ description: 'Argparse example'
36
+ });
37
+ parser.addArgument(
38
+ [ '-f', '--foo' ],
39
+ {
40
+ help: 'foo bar'
41
+ }
42
+ );
43
+ parser.addArgument(
44
+ [ '-b', '--bar' ],
45
+ {
46
+ help: 'bar foo'
47
+ }
48
+ );
49
+ parser.addArgument(
50
+ '--baz',
51
+ {
52
+ help: 'baz bar'
53
+ }
54
+ );
55
+ var args = parser.parseArgs();
56
+ console.dir(args);
57
+ ```
58
+
59
+ Display help:
60
+
61
+ ```
62
+ $ ./test.js -h
63
+ usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
64
+
65
+ Argparse example
66
+
67
+ Optional arguments:
68
+ -h, --help Show this help message and exit.
69
+ -v, --version Show program's version number and exit.
70
+ -f FOO, --foo FOO foo bar
71
+ -b BAR, --bar BAR bar foo
72
+ --baz BAZ baz bar
73
+ ```
74
+
75
+ Parse arguments:
76
+
77
+ ```
78
+ $ ./test.js -f=3 --bar=4 --baz 5
79
+ { foo: '3', bar: '4', baz: '5' }
80
+ ```
81
+
82
+ More [examples](https://github.com/nodeca/argparse/tree/master/examples).
83
+
84
+
85
+ ArgumentParser objects
86
+ ======================
87
+
88
+ ```
89
+ new ArgumentParser({parameters hash});
90
+ ```
91
+
92
+ Creates a new ArgumentParser object.
93
+
94
+ **Supported params:**
95
+
96
+ - ```description``` - Text to display before the argument help.
97
+ - ```epilog``` - Text to display after the argument help.
98
+ - ```addHelp``` - Add a -h/–help option to the parser. (default: true)
99
+ - ```argumentDefault``` - Set the global default value for arguments. (default: null)
100
+ - ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
101
+ - ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
102
+ - ```formatterClass``` - A class for customizing the help output.
103
+ - ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
104
+ - ```usage``` - The string describing the program usage (default: generated)
105
+ - ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
106
+
107
+ **Not supported yet**
108
+
109
+ - ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
110
+
111
+
112
+ Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
113
+
114
+
115
+ addArgument() method
116
+ ====================
117
+
118
+ ```
119
+ ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
120
+ ```
121
+
122
+ Defines how a single command-line argument should be parsed.
123
+
124
+ - ```name or flag or [name] or [flags...]``` - Either a positional name
125
+ (e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
126
+ of a single positional name (e.g., `['foo']`), or an array of options
127
+ (e.g., `['-f', '--foo']`).
128
+
129
+ Options:
130
+
131
+ - ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
132
+ - ```nargs```- The number of command-line arguments that should be consumed.
133
+ - ```constant``` - A constant value required by some action and nargs selections.
134
+ - ```defaultValue``` - The value produced if the argument is absent from the command line.
135
+ - ```type``` - The type to which the command-line argument should be converted.
136
+ - ```choices``` - A container of the allowable values for the argument.
137
+ - ```required``` - Whether or not the command-line option may be omitted (optionals only).
138
+ - ```help``` - A brief description of what the argument does.
139
+ - ```metavar``` - A name for the argument in usage messages.
140
+ - ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
141
+
142
+ Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
143
+
144
+
145
+ Action (some details)
146
+ ================
147
+
148
+ ArgumentParser objects associate command-line arguments with actions.
149
+ These actions can do just about anything with the command-line arguments associated
150
+ with them, though most actions simply add an attribute to the object returned by
151
+ parseArgs(). The action keyword argument specifies how the command-line arguments
152
+ should be handled. The supported actions are:
153
+
154
+ - ```store``` - Just stores the argument’s value. This is the default action.
155
+ - ```storeConst``` - Stores value, specified by the const keyword argument.
156
+ (Note that the const keyword argument defaults to the rather unhelpful None.)
157
+ The 'storeConst' action is most commonly used with optional arguments, that
158
+ specify some sort of flag.
159
+ - ```storeTrue``` and ```storeFalse``` - Stores values True and False
160
+ respectively. These are special cases of 'storeConst'.
161
+ - ```append``` - Stores a list, and appends each argument value to the list.
162
+ This is useful to allow an option to be specified multiple times.
163
+ - ```appendConst``` - Stores a list, and appends value, specified by the
164
+ const keyword argument to the list. (Note, that the const keyword argument defaults
165
+ is None.) The 'appendConst' action is typically used when multiple arguments need
166
+ to store constants to the same list.
167
+ - ```count``` - Counts the number of times a keyword argument occurs. For example,
168
+ used for increasing verbosity levels.
169
+ - ```help``` - Prints a complete help message for all the options in the current
170
+ parser and then exits. By default a help action is automatically added to the parser.
171
+ See ArgumentParser for details of how the output is created.
172
+ - ```version``` - Prints version information and exit. Expects a `version=`
173
+ keyword argument in the addArgument() call.
174
+
175
+ Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
176
+
177
+
178
+ Sub-commands
179
+ ============
180
+
181
+ ArgumentParser.addSubparsers()
182
+
183
+ Many programs split their functionality into a number of sub-commands, for
184
+ example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
185
+ and `svn commit`. Splitting up functionality this way can be a particularly good
186
+ idea when a program performs several different functions which require different
187
+ kinds of command-line arguments. `ArgumentParser` supports creation of such
188
+ sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
189
+ normally called with no arguments and returns an special action object.
190
+ This object has a single method `addParser()`, which takes a command name and
191
+ any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
192
+ that can be modified as usual.
193
+
194
+ Example:
195
+
196
+ sub_commands.js
197
+ ```javascript
198
+ #!/usr/bin/env node
199
+ 'use strict';
200
+
201
+ var ArgumentParser = require('../lib/argparse').ArgumentParser;
202
+ var parser = new ArgumentParser({
203
+ version: '0.0.1',
204
+ addHelp:true,
205
+ description: 'Argparse examples: sub-commands',
206
+ });
207
+
208
+ var subparsers = parser.addSubparsers({
209
+ title:'subcommands',
210
+ dest:"subcommand_name"
211
+ });
212
+
213
+ var bar = subparsers.addParser('c1', {addHelp:true});
214
+ bar.addArgument(
215
+ [ '-f', '--foo' ],
216
+ {
217
+ action: 'store',
218
+ help: 'foo3 bar3'
219
+ }
220
+ );
221
+ var bar = subparsers.addParser(
222
+ 'c2',
223
+ {aliases:['co'], addHelp:true}
224
+ );
225
+ bar.addArgument(
226
+ [ '-b', '--bar' ],
227
+ {
228
+ action: 'store',
229
+ type: 'int',
230
+ help: 'foo3 bar3'
231
+ }
232
+ );
233
+
234
+ var args = parser.parseArgs();
235
+ console.dir(args);
236
+
237
+ ```
238
+
239
+ Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
240
+
241
+
242
+ Contributors
243
+ ============
244
+
245
+ - [Eugene Shkuropat](https://github.com/shkuropat)
246
+ - [Paul Jacobson](https://github.com/hpaulj)
247
+
248
+ [others](https://github.com/nodeca/argparse/graphs/contributors)
249
+
250
+ License
251
+ =======
252
+
253
+ Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
254
+ Released under the MIT license. See
255
+ [LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
256
+
257
+
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./lib/argparse');
@@ -0,0 +1,47 @@
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 (typeof 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
+ };
@@ -0,0 +1,53 @@
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 c = 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 !== c.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 = (namespace[this.dest] || []).slice();
51
+ items.push(values);
52
+ namespace.set(this.dest, items);
53
+ };
@@ -0,0 +1,40 @@
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
+ };
@@ -0,0 +1,47 @@
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 c = 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
+ } else {
26
+ options.defaultValue = c.SUPPRESS;
27
+ }
28
+ options.dest = (options.dest !== null ? options.dest : c.SUPPRESS);
29
+ options.nargs = 0;
30
+ Action.call(this, options);
31
+
32
+ };
33
+ util.inherits(ActionHelp, Action);
34
+
35
+ /*:nodoc:*
36
+ * ActionHelp#call(parser, namespace, values, optionString)
37
+ * - parser (ArgumentParser): current parser
38
+ * - namespace (Namespace): namespace for output data
39
+ * - values (Array): parsed values
40
+ * - optionString (Array): input option string(not parsed)
41
+ *
42
+ * Print help and exit
43
+ **/
44
+ ActionHelp.prototype.call = function (parser) {
45
+ parser.printHelp();
46
+ parser.exit();
47
+ };
@@ -0,0 +1,43 @@
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 (typeof 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
+ };
@@ -0,0 +1,27 @@
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);
@@ -0,0 +1,26 @@
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);
@@ -0,0 +1,50 @@
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 c = 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 (typeof this.constant !== 'undefined' && this.nargs !== c.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
+ };