coa 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/.npmignore +6 -0
- package/.nyc_output/1f2a0db5a6d6559149db56d397f47cfc.json +1 -0
- package/.nyc_output/75b82d38f2186df930141082076e11c6.json +1 -0
- package/.travis.yml +9 -0
- package/GNUmakefile +34 -0
- package/README.md +1 -19
- package/coverage/base.css +212 -0
- package/coverage/coa/index.html +93 -0
- package/coverage/coa/index.js.html +68 -0
- package/coverage/coa/lib/arg.js.html +239 -0
- package/coverage/coa/lib/cmd.js.html +1556 -0
- package/coverage/coa/lib/coaobject.js.html +365 -0
- package/coverage/coa/lib/coaparam.js.html +440 -0
- package/coverage/coa/lib/color.js.html +131 -0
- package/coverage/coa/lib/completion.js.html +593 -0
- package/coverage/coa/lib/index.html +197 -0
- package/coverage/coa/lib/index.js.html +107 -0
- package/coverage/coa/lib/opt.js.html +524 -0
- package/coverage/coa/lib/shell.js.html +107 -0
- package/coverage/index.html +106 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +1 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +158 -0
- package/index.js +1 -1
- package/lib/arg.js +161 -44
- package/lib/cmd.js +547 -434
- package/lib/color.js +22 -19
- package/lib/completion.js +119 -161
- package/lib/index.js +10 -14
- package/lib/opt.js +313 -130
- package/lib/shell.js +13 -13
- package/package.json +14 -19
- package/qq.js +17 -0
- package/src/arg.coffee +130 -0
- package/src/cmd.coffee +456 -0
- package/src/color.coffee +25 -0
- package/src/completion.coffee +156 -0
- package/src/index.coffee +5 -0
- package/src/opt.coffee +243 -0
- package/src/shell.coffee +10 -0
- package/test/coa.js +496 -0
- package/test/mocha.opts +2 -0
- package/test/shell-test.js +60 -0
- package/tests/api-h.js +9 -0
- package/tests/h.js +6 -0
- package/LICENSE +0 -21
- package/lib/coaobject.js +0 -100
- package/lib/coaparam.js +0 -125
@@ -0,0 +1,365 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Code coverage report for coa/lib/coaobject.js</title>
|
5
|
+
<meta charset="utf-8" />
|
6
|
+
<link rel="stylesheet" href="../../prettify.css" />
|
7
|
+
<link rel="stylesheet" href="../../base.css" />
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
9
|
+
<style type='text/css'>
|
10
|
+
.coverage-summary .sorter {
|
11
|
+
background-image: url(../../sort-arrow-sprite.png);
|
12
|
+
}
|
13
|
+
</style>
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<div class='wrapper'>
|
17
|
+
<div class='pad1'>
|
18
|
+
<h1>
|
19
|
+
<a href="../../index.html">All files</a> / <a href="index.html">coa/lib</a> coaobject.js
|
20
|
+
</h1>
|
21
|
+
<div class='clearfix'>
|
22
|
+
<div class='fl pad1y space-right2'>
|
23
|
+
<span class="strong">75% </span>
|
24
|
+
<span class="quiet">Statements</span>
|
25
|
+
<span class='fraction'>12/16</span>
|
26
|
+
</div>
|
27
|
+
<div class='fl pad1y space-right2'>
|
28
|
+
<span class="strong">50% </span>
|
29
|
+
<span class="quiet">Branches</span>
|
30
|
+
<span class='fraction'>1/2</span>
|
31
|
+
</div>
|
32
|
+
<div class='fl pad1y space-right2'>
|
33
|
+
<span class="strong">71.43% </span>
|
34
|
+
<span class="quiet">Functions</span>
|
35
|
+
<span class='fraction'>5/7</span>
|
36
|
+
</div>
|
37
|
+
<div class='fl pad1y space-right2'>
|
38
|
+
<span class="strong">75% </span>
|
39
|
+
<span class="quiet">Lines</span>
|
40
|
+
<span class='fraction'>12/16</span>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
<div class='status-line medium'></div>
|
45
|
+
<pre><table class="coverage">
|
46
|
+
<tr><td class="line-count quiet">1
|
47
|
+
2
|
48
|
+
3
|
49
|
+
4
|
50
|
+
5
|
51
|
+
6
|
52
|
+
7
|
53
|
+
8
|
54
|
+
9
|
55
|
+
10
|
56
|
+
11
|
57
|
+
12
|
58
|
+
13
|
59
|
+
14
|
60
|
+
15
|
61
|
+
16
|
62
|
+
17
|
63
|
+
18
|
64
|
+
19
|
65
|
+
20
|
66
|
+
21
|
67
|
+
22
|
68
|
+
23
|
69
|
+
24
|
70
|
+
25
|
71
|
+
26
|
72
|
+
27
|
73
|
+
28
|
74
|
+
29
|
75
|
+
30
|
76
|
+
31
|
77
|
+
32
|
78
|
+
33
|
79
|
+
34
|
80
|
+
35
|
81
|
+
36
|
82
|
+
37
|
83
|
+
38
|
84
|
+
39
|
85
|
+
40
|
86
|
+
41
|
87
|
+
42
|
88
|
+
43
|
89
|
+
44
|
90
|
+
45
|
91
|
+
46
|
92
|
+
47
|
93
|
+
48
|
94
|
+
49
|
95
|
+
50
|
96
|
+
51
|
97
|
+
52
|
98
|
+
53
|
99
|
+
54
|
100
|
+
55
|
101
|
+
56
|
102
|
+
57
|
103
|
+
58
|
104
|
+
59
|
105
|
+
60
|
106
|
+
61
|
107
|
+
62
|
108
|
+
63
|
109
|
+
64
|
110
|
+
65
|
111
|
+
66
|
112
|
+
67
|
113
|
+
68
|
114
|
+
69
|
115
|
+
70
|
116
|
+
71
|
117
|
+
72
|
118
|
+
73
|
119
|
+
74
|
120
|
+
75
|
121
|
+
76
|
122
|
+
77
|
123
|
+
78
|
124
|
+
79
|
125
|
+
80
|
126
|
+
81
|
127
|
+
82
|
128
|
+
83
|
129
|
+
84
|
130
|
+
85
|
131
|
+
86
|
132
|
+
87
|
133
|
+
88
|
134
|
+
89
|
135
|
+
90
|
136
|
+
91
|
137
|
+
92
|
138
|
+
93
|
139
|
+
94
|
140
|
+
95
|
141
|
+
96
|
142
|
+
97
|
143
|
+
98
|
144
|
+
99
|
145
|
+
100
|
146
|
+
101</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
147
|
+
<span class="cline-any cline-neutral"> </span>
|
148
|
+
<span class="cline-any cline-yes">1x</span>
|
149
|
+
<span class="cline-any cline-neutral"> </span>
|
150
|
+
<span class="cline-any cline-neutral"> </span>
|
151
|
+
<span class="cline-any cline-neutral"> </span>
|
152
|
+
<span class="cline-any cline-neutral"> </span>
|
153
|
+
<span class="cline-any cline-neutral"> </span>
|
154
|
+
<span class="cline-any cline-neutral"> </span>
|
155
|
+
<span class="cline-any cline-neutral"> </span>
|
156
|
+
<span class="cline-any cline-neutral"> </span>
|
157
|
+
<span class="cline-any cline-neutral"> </span>
|
158
|
+
<span class="cline-any cline-neutral"> </span>
|
159
|
+
<span class="cline-any cline-neutral"> </span>
|
160
|
+
<span class="cline-any cline-neutral"> </span>
|
161
|
+
<span class="cline-any cline-neutral"> </span>
|
162
|
+
<span class="cline-any cline-neutral"> </span>
|
163
|
+
<span class="cline-any cline-neutral"> </span>
|
164
|
+
<span class="cline-any cline-neutral"> </span>
|
165
|
+
<span class="cline-any cline-neutral"> </span>
|
166
|
+
<span class="cline-any cline-neutral"> </span>
|
167
|
+
<span class="cline-any cline-yes">1x</span>
|
168
|
+
<span class="cline-any cline-neutral"> </span>
|
169
|
+
<span class="cline-any cline-yes">58x</span>
|
170
|
+
<span class="cline-any cline-yes">58x</span>
|
171
|
+
<span class="cline-any cline-yes">58x</span>
|
172
|
+
<span class="cline-any cline-yes">58x</span>
|
173
|
+
<span class="cline-any cline-neutral"> </span>
|
174
|
+
<span class="cline-any cline-neutral"> </span>
|
175
|
+
<span class="cline-any cline-neutral"> </span>
|
176
|
+
<span class="cline-any cline-neutral"> </span>
|
177
|
+
<span class="cline-any cline-neutral"> </span>
|
178
|
+
<span class="cline-any cline-neutral"> </span>
|
179
|
+
<span class="cline-any cline-neutral"> </span>
|
180
|
+
<span class="cline-any cline-neutral"> </span>
|
181
|
+
<span class="cline-any cline-neutral"> </span>
|
182
|
+
<span class="cline-any cline-yes">44x</span>
|
183
|
+
<span class="cline-any cline-yes">44x</span>
|
184
|
+
<span class="cline-any cline-neutral"> </span>
|
185
|
+
<span class="cline-any cline-neutral"> </span>
|
186
|
+
<span class="cline-any cline-neutral"> </span>
|
187
|
+
<span class="cline-any cline-neutral"> </span>
|
188
|
+
<span class="cline-any cline-neutral"> </span>
|
189
|
+
<span class="cline-any cline-neutral"> </span>
|
190
|
+
<span class="cline-any cline-neutral"> </span>
|
191
|
+
<span class="cline-any cline-neutral"> </span>
|
192
|
+
<span class="cline-any cline-no"> </span>
|
193
|
+
<span class="cline-any cline-no"> </span>
|
194
|
+
<span class="cline-any cline-neutral"> </span>
|
195
|
+
<span class="cline-any cline-neutral"> </span>
|
196
|
+
<span class="cline-any cline-neutral"> </span>
|
197
|
+
<span class="cline-any cline-neutral"> </span>
|
198
|
+
<span class="cline-any cline-neutral"> </span>
|
199
|
+
<span class="cline-any cline-neutral"> </span>
|
200
|
+
<span class="cline-any cline-neutral"> </span>
|
201
|
+
<span class="cline-any cline-neutral"> </span>
|
202
|
+
<span class="cline-any cline-neutral"> </span>
|
203
|
+
<span class="cline-any cline-neutral"> </span>
|
204
|
+
<span class="cline-any cline-neutral"> </span>
|
205
|
+
<span class="cline-any cline-neutral"> </span>
|
206
|
+
<span class="cline-any cline-neutral"> </span>
|
207
|
+
<span class="cline-any cline-no"> </span>
|
208
|
+
<span class="cline-any cline-no"> </span>
|
209
|
+
<span class="cline-any cline-neutral"> </span>
|
210
|
+
<span class="cline-any cline-neutral"> </span>
|
211
|
+
<span class="cline-any cline-neutral"> </span>
|
212
|
+
<span class="cline-any cline-neutral"> </span>
|
213
|
+
<span class="cline-any cline-neutral"> </span>
|
214
|
+
<span class="cline-any cline-neutral"> </span>
|
215
|
+
<span class="cline-any cline-neutral"> </span>
|
216
|
+
<span class="cline-any cline-neutral"> </span>
|
217
|
+
<span class="cline-any cline-neutral"> </span>
|
218
|
+
<span class="cline-any cline-neutral"> </span>
|
219
|
+
<span class="cline-any cline-yes">3x</span>
|
220
|
+
<span class="cline-any cline-neutral"> </span>
|
221
|
+
<span class="cline-any cline-neutral"> </span>
|
222
|
+
<span class="cline-any cline-neutral"> </span>
|
223
|
+
<span class="cline-any cline-yes">3x</span>
|
224
|
+
<span class="cline-any cline-neutral"> </span>
|
225
|
+
<span class="cline-any cline-neutral"> </span>
|
226
|
+
<span class="cline-any cline-neutral"> </span>
|
227
|
+
<span class="cline-any cline-neutral"> </span>
|
228
|
+
<span class="cline-any cline-neutral"> </span>
|
229
|
+
<span class="cline-any cline-neutral"> </span>
|
230
|
+
<span class="cline-any cline-neutral"> </span>
|
231
|
+
<span class="cline-any cline-neutral"> </span>
|
232
|
+
<span class="cline-any cline-neutral"> </span>
|
233
|
+
<span class="cline-any cline-neutral"> </span>
|
234
|
+
<span class="cline-any cline-neutral"> </span>
|
235
|
+
<span class="cline-any cline-yes">8x</span>
|
236
|
+
<span class="cline-any cline-neutral"> </span>
|
237
|
+
<span class="cline-any cline-neutral"> </span>
|
238
|
+
<span class="cline-any cline-neutral"> </span>
|
239
|
+
<span class="cline-any cline-neutral"> </span>
|
240
|
+
<span class="cline-any cline-neutral"> </span>
|
241
|
+
<span class="cline-any cline-neutral"> </span>
|
242
|
+
<span class="cline-any cline-neutral"> </span>
|
243
|
+
<span class="cline-any cline-yes">38x</span>
|
244
|
+
<span class="cline-any cline-neutral"> </span>
|
245
|
+
<span class="cline-any cline-neutral"> </span>
|
246
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
247
|
+
|
248
|
+
const Q = require('q');
|
249
|
+
|
250
|
+
/**
|
251
|
+
* COA Object
|
252
|
+
*
|
253
|
+
* Base class for all COA-related objects
|
254
|
+
*
|
255
|
+
* --------|-----|-----|-----
|
256
|
+
* | Cmd | Opt | Arg
|
257
|
+
* --------|-----|-----|-----
|
258
|
+
* name | ✓ | ✓ | ✓
|
259
|
+
* title | ✓ | ✓ | ✓
|
260
|
+
* comp | ✓ | ✓ | ✓
|
261
|
+
* reject | ✓ | ✓ | ✓
|
262
|
+
* end | ✓ | ✓ | ✓
|
263
|
+
* apply | ✓ | ✓ | ✓
|
264
|
+
*
|
265
|
+
* @class CoaObject
|
266
|
+
*/
|
267
|
+
module.exports = class CoaObject {
|
268
|
+
constructor(cmd) {
|
269
|
+
this._cmd = cmd;
|
270
|
+
this._name = null;
|
271
|
+
this._title = null;
|
272
|
+
this._comp = null;
|
273
|
+
}
|
274
|
+
|
275
|
+
/**
|
276
|
+
* Set a canonical identifier to be used anywhere in the API.
|
277
|
+
*
|
278
|
+
* @param {String} name - command, option or argument name
|
279
|
+
* @returns {COA.CoaObject} - this instance (for chainability)
|
280
|
+
*/
|
281
|
+
name(name) {
|
282
|
+
this._name = name;
|
283
|
+
return this;
|
284
|
+
}
|
285
|
+
|
286
|
+
/**
|
287
|
+
* Set a long description to be used anywhere in text messages.
|
288
|
+
* @param {String} title - human readable entity title
|
289
|
+
* @returns {COA.CoaObject} - this instance (for chainability)
|
290
|
+
*/
|
291
|
+
<span class="fstat-no" title="function not covered" > ti</span>tle(title) {
|
292
|
+
<span class="cstat-no" title="statement not covered" > this._title = title;</span>
|
293
|
+
<span class="cstat-no" title="statement not covered" > return this;</span>
|
294
|
+
}
|
295
|
+
|
296
|
+
/**
|
297
|
+
* Set custom additional completion for current object.
|
298
|
+
*
|
299
|
+
* @param {Function} comp - completion generation function,
|
300
|
+
* invoked in the context of object instance.
|
301
|
+
* Accepts parameters:
|
302
|
+
* - {Object} opts - completion options
|
303
|
+
* It can return promise or any other value threated as a result.
|
304
|
+
* @returns {COA.CoaObject} - this instance (for chainability)
|
305
|
+
*/
|
306
|
+
<span class="fstat-no" title="function not covered" > co</span>mp(comp) {
|
307
|
+
<span class="cstat-no" title="statement not covered" > this._comp = comp;</span>
|
308
|
+
<span class="cstat-no" title="statement not covered" > return this;</span>
|
309
|
+
}
|
310
|
+
|
311
|
+
/**
|
312
|
+
* Apply function with arguments in a context of object instance.
|
313
|
+
*
|
314
|
+
* @param {Function} fn - body
|
315
|
+
* @param {Array.<*>} args... - arguments
|
316
|
+
* @returns {COA.CoaObject} - this instance (for chainability)
|
317
|
+
*/
|
318
|
+
apply(fn) {
|
319
|
+
arguments.length > 1?
|
320
|
+
<span class="branch-0 cbranch-no" title="branch not covered" > fn.apply(this, [].slice.call(arguments, 1))</span>
|
321
|
+
: fn.call(this);
|
322
|
+
|
323
|
+
return this;
|
324
|
+
}
|
325
|
+
|
326
|
+
/**
|
327
|
+
* Return reject of actions results promise with error code.
|
328
|
+
* Use in .act() for return with error.
|
329
|
+
* @param {Object} reason - reject reason
|
330
|
+
* You can customize toString() method and exitCode property
|
331
|
+
* of reason object.
|
332
|
+
* @returns {Q.promise} rejected promise
|
333
|
+
*/
|
334
|
+
reject(reason) {
|
335
|
+
return Q.reject(reason);
|
336
|
+
}
|
337
|
+
|
338
|
+
/**
|
339
|
+
* Finish chain for current subcommand and return parent command instance.
|
340
|
+
* @returns {COA.Cmd} parent command
|
341
|
+
*/
|
342
|
+
end() {
|
343
|
+
return this._cmd;
|
344
|
+
}
|
345
|
+
};
|
346
|
+
</pre></td></tr>
|
347
|
+
</table></pre>
|
348
|
+
<div class='push'></div><!-- for sticky footer -->
|
349
|
+
</div><!-- /wrapper -->
|
350
|
+
<div class='footer quiet pad2 space-top1 center small'>
|
351
|
+
Code coverage
|
352
|
+
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
353
|
+
</div>
|
354
|
+
</div>
|
355
|
+
<script src="../../prettify.js"></script>
|
356
|
+
<script>
|
357
|
+
window.onload = function () {
|
358
|
+
if (typeof prettyPrint === 'function') {
|
359
|
+
prettyPrint();
|
360
|
+
}
|
361
|
+
};
|
362
|
+
</script>
|
363
|
+
<script src="../../sorter.js"></script>
|
364
|
+
</body>
|
365
|
+
</html>
|