coa 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/.npmignore +6 -0
  2. package/.nyc_output/1f2a0db5a6d6559149db56d397f47cfc.json +1 -0
  3. package/.nyc_output/75b82d38f2186df930141082076e11c6.json +1 -0
  4. package/.travis.yml +9 -0
  5. package/GNUmakefile +34 -0
  6. package/README.md +1 -19
  7. package/coverage/base.css +212 -0
  8. package/coverage/coa/index.html +93 -0
  9. package/coverage/coa/index.js.html +68 -0
  10. package/coverage/coa/lib/arg.js.html +239 -0
  11. package/coverage/coa/lib/cmd.js.html +1556 -0
  12. package/coverage/coa/lib/coaobject.js.html +365 -0
  13. package/coverage/coa/lib/coaparam.js.html +440 -0
  14. package/coverage/coa/lib/color.js.html +131 -0
  15. package/coverage/coa/lib/completion.js.html +593 -0
  16. package/coverage/coa/lib/index.html +197 -0
  17. package/coverage/coa/lib/index.js.html +107 -0
  18. package/coverage/coa/lib/opt.js.html +524 -0
  19. package/coverage/coa/lib/shell.js.html +107 -0
  20. package/coverage/index.html +106 -0
  21. package/coverage/prettify.css +1 -0
  22. package/coverage/prettify.js +1 -0
  23. package/coverage/sort-arrow-sprite.png +0 -0
  24. package/coverage/sorter.js +158 -0
  25. package/index.js +1 -1
  26. package/lib/arg.js +161 -44
  27. package/lib/cmd.js +547 -434
  28. package/lib/color.js +22 -19
  29. package/lib/completion.js +119 -161
  30. package/lib/index.js +10 -14
  31. package/lib/opt.js +313 -130
  32. package/lib/shell.js +13 -13
  33. package/package.json +14 -19
  34. package/qq.js +17 -0
  35. package/src/arg.coffee +130 -0
  36. package/src/cmd.coffee +456 -0
  37. package/src/color.coffee +25 -0
  38. package/src/completion.coffee +156 -0
  39. package/src/index.coffee +5 -0
  40. package/src/opt.coffee +243 -0
  41. package/src/shell.coffee +10 -0
  42. package/test/coa.js +496 -0
  43. package/test/mocha.opts +2 -0
  44. package/test/shell-test.js +60 -0
  45. package/tests/api-h.js +9 -0
  46. package/tests/h.js +6 -0
  47. package/LICENSE +0 -21
  48. package/lib/coaobject.js +0 -100
  49. package/lib/coaparam.js +0 -125
@@ -0,0 +1,1556 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Code coverage report for coa/lib/cmd.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> cmd.js
20
+ </h1>
21
+ <div class='clearfix'>
22
+ <div class='fl pad1y space-right2'>
23
+ <span class="strong">81.22% </span>
24
+ <span class="quiet">Statements</span>
25
+ <span class='fraction'>147/181</span>
26
+ </div>
27
+ <div class='fl pad1y space-right2'>
28
+ <span class="strong">71.64% </span>
29
+ <span class="quiet">Branches</span>
30
+ <span class='fraction'>96/134</span>
31
+ </div>
32
+ <div class='fl pad1y space-right2'>
33
+ <span class="strong">68.75% </span>
34
+ <span class="quiet">Functions</span>
35
+ <span class='fraction'>33/48</span>
36
+ </div>
37
+ <div class='fl pad1y space-right2'>
38
+ <span class="strong">82.53% </span>
39
+ <span class="quiet">Lines</span>
40
+ <span class='fraction'>137/166</span>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ <div class='status-line high'></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
147
+ 102
148
+ 103
149
+ 104
150
+ 105
151
+ 106
152
+ 107
153
+ 108
154
+ 109
155
+ 110
156
+ 111
157
+ 112
158
+ 113
159
+ 114
160
+ 115
161
+ 116
162
+ 117
163
+ 118
164
+ 119
165
+ 120
166
+ 121
167
+ 122
168
+ 123
169
+ 124
170
+ 125
171
+ 126
172
+ 127
173
+ 128
174
+ 129
175
+ 130
176
+ 131
177
+ 132
178
+ 133
179
+ 134
180
+ 135
181
+ 136
182
+ 137
183
+ 138
184
+ 139
185
+ 140
186
+ 141
187
+ 142
188
+ 143
189
+ 144
190
+ 145
191
+ 146
192
+ 147
193
+ 148
194
+ 149
195
+ 150
196
+ 151
197
+ 152
198
+ 153
199
+ 154
200
+ 155
201
+ 156
202
+ 157
203
+ 158
204
+ 159
205
+ 160
206
+ 161
207
+ 162
208
+ 163
209
+ 164
210
+ 165
211
+ 166
212
+ 167
213
+ 168
214
+ 169
215
+ 170
216
+ 171
217
+ 172
218
+ 173
219
+ 174
220
+ 175
221
+ 176
222
+ 177
223
+ 178
224
+ 179
225
+ 180
226
+ 181
227
+ 182
228
+ 183
229
+ 184
230
+ 185
231
+ 186
232
+ 187
233
+ 188
234
+ 189
235
+ 190
236
+ 191
237
+ 192
238
+ 193
239
+ 194
240
+ 195
241
+ 196
242
+ 197
243
+ 198
244
+ 199
245
+ 200
246
+ 201
247
+ 202
248
+ 203
249
+ 204
250
+ 205
251
+ 206
252
+ 207
253
+ 208
254
+ 209
255
+ 210
256
+ 211
257
+ 212
258
+ 213
259
+ 214
260
+ 215
261
+ 216
262
+ 217
263
+ 218
264
+ 219
265
+ 220
266
+ 221
267
+ 222
268
+ 223
269
+ 224
270
+ 225
271
+ 226
272
+ 227
273
+ 228
274
+ 229
275
+ 230
276
+ 231
277
+ 232
278
+ 233
279
+ 234
280
+ 235
281
+ 236
282
+ 237
283
+ 238
284
+ 239
285
+ 240
286
+ 241
287
+ 242
288
+ 243
289
+ 244
290
+ 245
291
+ 246
292
+ 247
293
+ 248
294
+ 249
295
+ 250
296
+ 251
297
+ 252
298
+ 253
299
+ 254
300
+ 255
301
+ 256
302
+ 257
303
+ 258
304
+ 259
305
+ 260
306
+ 261
307
+ 262
308
+ 263
309
+ 264
310
+ 265
311
+ 266
312
+ 267
313
+ 268
314
+ 269
315
+ 270
316
+ 271
317
+ 272
318
+ 273
319
+ 274
320
+ 275
321
+ 276
322
+ 277
323
+ 278
324
+ 279
325
+ 280
326
+ 281
327
+ 282
328
+ 283
329
+ 284
330
+ 285
331
+ 286
332
+ 287
333
+ 288
334
+ 289
335
+ 290
336
+ 291
337
+ 292
338
+ 293
339
+ 294
340
+ 295
341
+ 296
342
+ 297
343
+ 298
344
+ 299
345
+ 300
346
+ 301
347
+ 302
348
+ 303
349
+ 304
350
+ 305
351
+ 306
352
+ 307
353
+ 308
354
+ 309
355
+ 310
356
+ 311
357
+ 312
358
+ 313
359
+ 314
360
+ 315
361
+ 316
362
+ 317
363
+ 318
364
+ 319
365
+ 320
366
+ 321
367
+ 322
368
+ 323
369
+ 324
370
+ 325
371
+ 326
372
+ 327
373
+ 328
374
+ 329
375
+ 330
376
+ 331
377
+ 332
378
+ 333
379
+ 334
380
+ 335
381
+ 336
382
+ 337
383
+ 338
384
+ 339
385
+ 340
386
+ 341
387
+ 342
388
+ 343
389
+ 344
390
+ 345
391
+ 346
392
+ 347
393
+ 348
394
+ 349
395
+ 350
396
+ 351
397
+ 352
398
+ 353
399
+ 354
400
+ 355
401
+ 356
402
+ 357
403
+ 358
404
+ 359
405
+ 360
406
+ 361
407
+ 362
408
+ 363
409
+ 364
410
+ 365
411
+ 366
412
+ 367
413
+ 368
414
+ 369
415
+ 370
416
+ 371
417
+ 372
418
+ 373
419
+ 374
420
+ 375
421
+ 376
422
+ 377
423
+ 378
424
+ 379
425
+ 380
426
+ 381
427
+ 382
428
+ 383
429
+ 384
430
+ 385
431
+ 386
432
+ 387
433
+ 388
434
+ 389
435
+ 390
436
+ 391
437
+ 392
438
+ 393
439
+ 394
440
+ 395
441
+ 396
442
+ 397
443
+ 398
444
+ 399
445
+ 400
446
+ 401
447
+ 402
448
+ 403
449
+ 404
450
+ 405
451
+ 406
452
+ 407
453
+ 408
454
+ 409
455
+ 410
456
+ 411
457
+ 412
458
+ 413
459
+ 414
460
+ 415
461
+ 416
462
+ 417
463
+ 418
464
+ 419
465
+ 420
466
+ 421
467
+ 422
468
+ 423
469
+ 424
470
+ 425
471
+ 426
472
+ 427
473
+ 428
474
+ 429
475
+ 430
476
+ 431
477
+ 432
478
+ 433
479
+ 434
480
+ 435
481
+ 436
482
+ 437
483
+ 438
484
+ 439
485
+ 440
486
+ 441
487
+ 442
488
+ 443
489
+ 444
490
+ 445
491
+ 446
492
+ 447
493
+ 448
494
+ 449
495
+ 450
496
+ 451
497
+ 452
498
+ 453
499
+ 454
500
+ 455
501
+ 456
502
+ 457
503
+ 458
504
+ 459
505
+ 460
506
+ 461
507
+ 462
508
+ 463
509
+ 464
510
+ 465
511
+ 466
512
+ 467
513
+ 468
514
+ 469
515
+ 470
516
+ 471
517
+ 472
518
+ 473
519
+ 474
520
+ 475
521
+ 476
522
+ 477
523
+ 478
524
+ 479
525
+ 480
526
+ 481
527
+ 482
528
+ 483
529
+ 484
530
+ 485
531
+ 486
532
+ 487
533
+ 488
534
+ 489
535
+ 490
536
+ 491
537
+ 492
538
+ 493
539
+ 494
540
+ 495
541
+ 496
542
+ 497
543
+ 498</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
544
+ <span class="cline-any cline-neutral">&nbsp;</span>
545
+ <span class="cline-any cline-neutral">&nbsp;</span>
546
+ <span class="cline-any cline-yes">1x</span>
547
+ <span class="cline-any cline-yes">1x</span>
548
+ <span class="cline-any cline-yes">1x</span>
549
+ <span class="cline-any cline-neutral">&nbsp;</span>
550
+ <span class="cline-any cline-yes">1x</span>
551
+ <span class="cline-any cline-neutral">&nbsp;</span>
552
+ <span class="cline-any cline-yes">1x</span>
553
+ <span class="cline-any cline-yes">1x</span>
554
+ <span class="cline-any cline-yes">1x</span>
555
+ <span class="cline-any cline-yes">1x</span>
556
+ <span class="cline-any cline-yes">1x</span>
557
+ <span class="cline-any cline-neutral">&nbsp;</span>
558
+ <span class="cline-any cline-neutral">&nbsp;</span>
559
+ <span class="cline-any cline-neutral">&nbsp;</span>
560
+ <span class="cline-any cline-neutral">&nbsp;</span>
561
+ <span class="cline-any cline-neutral">&nbsp;</span>
562
+ <span class="cline-any cline-neutral">&nbsp;</span>
563
+ <span class="cline-any cline-neutral">&nbsp;</span>
564
+ <span class="cline-any cline-neutral">&nbsp;</span>
565
+ <span class="cline-any cline-neutral">&nbsp;</span>
566
+ <span class="cline-any cline-neutral">&nbsp;</span>
567
+ <span class="cline-any cline-neutral">&nbsp;</span>
568
+ <span class="cline-any cline-neutral">&nbsp;</span>
569
+ <span class="cline-any cline-neutral">&nbsp;</span>
570
+ <span class="cline-any cline-neutral">&nbsp;</span>
571
+ <span class="cline-any cline-neutral">&nbsp;</span>
572
+ <span class="cline-any cline-neutral">&nbsp;</span>
573
+ <span class="cline-any cline-yes">26x</span>
574
+ <span class="cline-any cline-neutral">&nbsp;</span>
575
+ <span class="cline-any cline-yes">26x</span>
576
+ <span class="cline-any cline-yes">26x</span>
577
+ <span class="cline-any cline-yes">26x</span>
578
+ <span class="cline-any cline-yes">26x</span>
579
+ <span class="cline-any cline-yes">26x</span>
580
+ <span class="cline-any cline-yes">26x</span>
581
+ <span class="cline-any cline-yes">26x</span>
582
+ <span class="cline-any cline-yes">26x</span>
583
+ <span class="cline-any cline-neutral">&nbsp;</span>
584
+ <span class="cline-any cline-neutral">&nbsp;</span>
585
+ <span class="cline-any cline-neutral">&nbsp;</span>
586
+ <span class="cline-any cline-yes">21x</span>
587
+ <span class="cline-any cline-neutral">&nbsp;</span>
588
+ <span class="cline-any cline-neutral">&nbsp;</span>
589
+ <span class="cline-any cline-neutral">&nbsp;</span>
590
+ <span class="cline-any cline-neutral">&nbsp;</span>
591
+ <span class="cline-any cline-neutral">&nbsp;</span>
592
+ <span class="cline-any cline-neutral">&nbsp;</span>
593
+ <span class="cline-any cline-neutral">&nbsp;</span>
594
+ <span class="cline-any cline-neutral">&nbsp;</span>
595
+ <span class="cline-any cline-neutral">&nbsp;</span>
596
+ <span class="cline-any cline-neutral">&nbsp;</span>
597
+ <span class="cline-any cline-yes">2x</span>
598
+ <span class="cline-any cline-yes">2x</span>
599
+ <span class="cline-any cline-yes">1x</span>
600
+ <span class="cline-any cline-neutral">&nbsp;</span>
601
+ <span class="cline-any cline-neutral">&nbsp;</span>
602
+ <span class="cline-any cline-yes">2x</span>
603
+ <span class="cline-any cline-yes">2x</span>
604
+ <span class="cline-any cline-yes">1x</span>
605
+ <span class="cline-any cline-neutral">&nbsp;</span>
606
+ <span class="cline-any cline-yes">2x</span>
607
+ <span class="cline-any cline-neutral">&nbsp;</span>
608
+ <span class="cline-any cline-neutral">&nbsp;</span>
609
+ <span class="cline-any cline-neutral">&nbsp;</span>
610
+ <span class="cline-any cline-yes">28x</span>
611
+ <span class="cline-any cline-neutral">&nbsp;</span>
612
+ <span class="cline-any cline-yes">28x</span>
613
+ <span class="cline-any cline-neutral">&nbsp;</span>
614
+ <span class="cline-any cline-neutral">&nbsp;</span>
615
+ <span class="cline-any cline-neutral">&nbsp;</span>
616
+ <span class="cline-any cline-neutral">&nbsp;</span>
617
+ <span class="cline-any cline-yes">28x</span>
618
+ <span class="cline-any cline-neutral">&nbsp;</span>
619
+ <span class="cline-any cline-neutral">&nbsp;</span>
620
+ <span class="cline-any cline-neutral">&nbsp;</span>
621
+ <span class="cline-any cline-yes">44x</span>
622
+ <span class="cline-any cline-neutral">&nbsp;</span>
623
+ <span class="cline-any cline-neutral">&nbsp;</span>
624
+ <span class="cline-any cline-neutral">&nbsp;</span>
625
+ <span class="cline-any cline-neutral">&nbsp;</span>
626
+ <span class="cline-any cline-neutral">&nbsp;</span>
627
+ <span class="cline-any cline-neutral">&nbsp;</span>
628
+ <span class="cline-any cline-neutral">&nbsp;</span>
629
+ <span class="cline-any cline-neutral">&nbsp;</span>
630
+ <span class="cline-any cline-neutral">&nbsp;</span>
631
+ <span class="cline-any cline-yes">12x</span>
632
+ <span class="cline-any cline-neutral">&nbsp;</span>
633
+ <span class="cline-any cline-yes">12x</span>
634
+ <span class="cline-any cline-neutral">&nbsp;</span>
635
+ <span class="cline-any cline-neutral">&nbsp;</span>
636
+ <span class="cline-any cline-yes">12x</span>
637
+ <span class="cline-any cline-neutral">&nbsp;</span>
638
+ <span class="cline-any cline-neutral">&nbsp;</span>
639
+ <span class="cline-any cline-neutral">&nbsp;</span>
640
+ <span class="cline-any cline-neutral">&nbsp;</span>
641
+ <span class="cline-any cline-neutral">&nbsp;</span>
642
+ <span class="cline-any cline-neutral">&nbsp;</span>
643
+ <span class="cline-any cline-neutral">&nbsp;</span>
644
+ <span class="cline-any cline-neutral">&nbsp;</span>
645
+ <span class="cline-any cline-neutral">&nbsp;</span>
646
+ <span class="cline-any cline-yes">7x</span>
647
+ <span class="cline-any cline-neutral">&nbsp;</span>
648
+ <span class="cline-any cline-neutral">&nbsp;</span>
649
+ <span class="cline-any cline-neutral">&nbsp;</span>
650
+ <span class="cline-any cline-neutral">&nbsp;</span>
651
+ <span class="cline-any cline-neutral">&nbsp;</span>
652
+ <span class="cline-any cline-neutral">&nbsp;</span>
653
+ <span class="cline-any cline-neutral">&nbsp;</span>
654
+ <span class="cline-any cline-neutral">&nbsp;</span>
655
+ <span class="cline-any cline-neutral">&nbsp;</span>
656
+ <span class="cline-any cline-neutral">&nbsp;</span>
657
+ <span class="cline-any cline-yes">16x</span>
658
+ <span class="cline-any cline-neutral">&nbsp;</span>
659
+ <span class="cline-any cline-neutral">&nbsp;</span>
660
+ <span class="cline-any cline-neutral">&nbsp;</span>
661
+ <span class="cline-any cline-neutral">&nbsp;</span>
662
+ <span class="cline-any cline-neutral">&nbsp;</span>
663
+ <span class="cline-any cline-neutral">&nbsp;</span>
664
+ <span class="cline-any cline-neutral">&nbsp;</span>
665
+ <span class="cline-any cline-neutral">&nbsp;</span>
666
+ <span class="cline-any cline-yes">16x</span>
667
+ <span class="cline-any cline-neutral">&nbsp;</span>
668
+ <span class="cline-any cline-neutral">&nbsp;</span>
669
+ <span class="cline-any cline-neutral">&nbsp;</span>
670
+ <span class="cline-any cline-neutral">&nbsp;</span>
671
+ <span class="cline-any cline-neutral">&nbsp;</span>
672
+ <span class="cline-any cline-neutral">&nbsp;</span>
673
+ <span class="cline-any cline-neutral">&nbsp;</span>
674
+ <span class="cline-any cline-neutral">&nbsp;</span>
675
+ <span class="cline-any cline-neutral">&nbsp;</span>
676
+ <span class="cline-any cline-neutral">&nbsp;</span>
677
+ <span class="cline-any cline-neutral">&nbsp;</span>
678
+ <span class="cline-any cline-neutral">&nbsp;</span>
679
+ <span class="cline-any cline-neutral">&nbsp;</span>
680
+ <span class="cline-any cline-neutral">&nbsp;</span>
681
+ <span class="cline-any cline-neutral">&nbsp;</span>
682
+ <span class="cline-any cline-neutral">&nbsp;</span>
683
+ <span class="cline-any cline-neutral">&nbsp;</span>
684
+ <span class="cline-any cline-yes">16x</span>
685
+ <span class="cline-any cline-neutral">&nbsp;</span>
686
+ <span class="cline-any cline-yes">16x</span>
687
+ <span class="cline-any cline-yes">16x</span>
688
+ <span class="cline-any cline-neutral">&nbsp;</span>
689
+ <span class="cline-any cline-yes">16x</span>
690
+ <span class="cline-any cline-neutral">&nbsp;</span>
691
+ <span class="cline-any cline-neutral">&nbsp;</span>
692
+ <span class="cline-any cline-neutral">&nbsp;</span>
693
+ <span class="cline-any cline-neutral">&nbsp;</span>
694
+ <span class="cline-any cline-neutral">&nbsp;</span>
695
+ <span class="cline-any cline-neutral">&nbsp;</span>
696
+ <span class="cline-any cline-neutral">&nbsp;</span>
697
+ <span class="cline-any cline-neutral">&nbsp;</span>
698
+ <span class="cline-any cline-no">&nbsp;</span>
699
+ <span class="cline-any cline-neutral">&nbsp;</span>
700
+ <span class="cline-any cline-neutral">&nbsp;</span>
701
+ <span class="cline-any cline-neutral">&nbsp;</span>
702
+ <span class="cline-any cline-neutral">&nbsp;</span>
703
+ <span class="cline-any cline-neutral">&nbsp;</span>
704
+ <span class="cline-any cline-neutral">&nbsp;</span>
705
+ <span class="cline-any cline-neutral">&nbsp;</span>
706
+ <span class="cline-any cline-no">&nbsp;</span>
707
+ <span class="cline-any cline-neutral">&nbsp;</span>
708
+ <span class="cline-any cline-neutral">&nbsp;</span>
709
+ <span class="cline-any cline-neutral">&nbsp;</span>
710
+ <span class="cline-any cline-neutral">&nbsp;</span>
711
+ <span class="cline-any cline-neutral">&nbsp;</span>
712
+ <span class="cline-any cline-neutral">&nbsp;</span>
713
+ <span class="cline-any cline-neutral">&nbsp;</span>
714
+ <span class="cline-any cline-neutral">&nbsp;</span>
715
+ <span class="cline-any cline-neutral">&nbsp;</span>
716
+ <span class="cline-any cline-neutral">&nbsp;</span>
717
+ <span class="cline-any cline-neutral">&nbsp;</span>
718
+ <span class="cline-any cline-neutral">&nbsp;</span>
719
+ <span class="cline-any cline-no">&nbsp;</span>
720
+ <span class="cline-any cline-neutral">&nbsp;</span>
721
+ <span class="cline-any cline-neutral">&nbsp;</span>
722
+ <span class="cline-any cline-neutral">&nbsp;</span>
723
+ <span class="cline-any cline-neutral">&nbsp;</span>
724
+ <span class="cline-any cline-neutral">&nbsp;</span>
725
+ <span class="cline-any cline-neutral">&nbsp;</span>
726
+ <span class="cline-any cline-neutral">&nbsp;</span>
727
+ <span class="cline-any cline-neutral">&nbsp;</span>
728
+ <span class="cline-any cline-neutral">&nbsp;</span>
729
+ <span class="cline-any cline-neutral">&nbsp;</span>
730
+ <span class="cline-any cline-neutral">&nbsp;</span>
731
+ <span class="cline-any cline-neutral">&nbsp;</span>
732
+ <span class="cline-any cline-yes">5x</span>
733
+ <span class="cline-any cline-yes">5x</span>
734
+ <span class="cline-any cline-neutral">&nbsp;</span>
735
+ <span class="cline-any cline-neutral">&nbsp;</span>
736
+ <span class="cline-any cline-neutral">&nbsp;</span>
737
+ <span class="cline-any cline-no">&nbsp;</span>
738
+ <span class="cline-any cline-no">&nbsp;</span>
739
+ <span class="cline-any cline-no">&nbsp;</span>
740
+ <span class="cline-any cline-neutral">&nbsp;</span>
741
+ <span class="cline-any cline-neutral">&nbsp;</span>
742
+ <span class="cline-any cline-neutral">&nbsp;</span>
743
+ <span class="cline-any cline-neutral">&nbsp;</span>
744
+ <span class="cline-any cline-neutral">&nbsp;</span>
745
+ <span class="cline-any cline-neutral">&nbsp;</span>
746
+ <span class="cline-any cline-neutral">&nbsp;</span>
747
+ <span class="cline-any cline-neutral">&nbsp;</span>
748
+ <span class="cline-any cline-neutral">&nbsp;</span>
749
+ <span class="cline-any cline-no">&nbsp;</span>
750
+ <span class="cline-any cline-neutral">&nbsp;</span>
751
+ <span class="cline-any cline-no">&nbsp;</span>
752
+ <span class="cline-any cline-neutral">&nbsp;</span>
753
+ <span class="cline-any cline-no">&nbsp;</span>
754
+ <span class="cline-any cline-neutral">&nbsp;</span>
755
+ <span class="cline-any cline-no">&nbsp;</span>
756
+ <span class="cline-any cline-neutral">&nbsp;</span>
757
+ <span class="cline-any cline-neutral">&nbsp;</span>
758
+ <span class="cline-any cline-neutral">&nbsp;</span>
759
+ <span class="cline-any cline-neutral">&nbsp;</span>
760
+ <span class="cline-any cline-neutral">&nbsp;</span>
761
+ <span class="cline-any cline-no">&nbsp;</span>
762
+ <span class="cline-any cline-neutral">&nbsp;</span>
763
+ <span class="cline-any cline-neutral">&nbsp;</span>
764
+ <span class="cline-any cline-neutral">&nbsp;</span>
765
+ <span class="cline-any cline-neutral">&nbsp;</span>
766
+ <span class="cline-any cline-neutral">&nbsp;</span>
767
+ <span class="cline-any cline-no">&nbsp;</span>
768
+ <span class="cline-any cline-neutral">&nbsp;</span>
769
+ <span class="cline-any cline-neutral">&nbsp;</span>
770
+ <span class="cline-any cline-neutral">&nbsp;</span>
771
+ <span class="cline-any cline-neutral">&nbsp;</span>
772
+ <span class="cline-any cline-neutral">&nbsp;</span>
773
+ <span class="cline-any cline-no">&nbsp;</span>
774
+ <span class="cline-any cline-neutral">&nbsp;</span>
775
+ <span class="cline-any cline-neutral">&nbsp;</span>
776
+ <span class="cline-any cline-neutral">&nbsp;</span>
777
+ <span class="cline-any cline-no">&nbsp;</span>
778
+ <span class="cline-any cline-neutral">&nbsp;</span>
779
+ <span class="cline-any cline-neutral">&nbsp;</span>
780
+ <span class="cline-any cline-neutral">&nbsp;</span>
781
+ <span class="cline-any cline-no">&nbsp;</span>
782
+ <span class="cline-any cline-neutral">&nbsp;</span>
783
+ <span class="cline-any cline-no">&nbsp;</span>
784
+ <span class="cline-any cline-no">&nbsp;</span>
785
+ <span class="cline-any cline-neutral">&nbsp;</span>
786
+ <span class="cline-any cline-neutral">&nbsp;</span>
787
+ <span class="cline-any cline-neutral">&nbsp;</span>
788
+ <span class="cline-any cline-neutral">&nbsp;</span>
789
+ <span class="cline-any cline-no">&nbsp;</span>
790
+ <span class="cline-any cline-neutral">&nbsp;</span>
791
+ <span class="cline-any cline-neutral">&nbsp;</span>
792
+ <span class="cline-any cline-neutral">&nbsp;</span>
793
+ <span class="cline-any cline-no">&nbsp;</span>
794
+ <span class="cline-any cline-neutral">&nbsp;</span>
795
+ <span class="cline-any cline-neutral">&nbsp;</span>
796
+ <span class="cline-any cline-neutral">&nbsp;</span>
797
+ <span class="cline-any cline-yes">19x</span>
798
+ <span class="cline-any cline-yes">19x</span>
799
+ <span class="cline-any cline-yes">1x</span>
800
+ <span class="cline-any cline-neutral">&nbsp;</span>
801
+ <span class="cline-any cline-yes">18x</span>
802
+ <span class="cline-any cline-neutral">&nbsp;</span>
803
+ <span class="cline-any cline-neutral">&nbsp;</span>
804
+ <span class="cline-any cline-neutral">&nbsp;</span>
805
+ <span class="cline-any cline-neutral">&nbsp;</span>
806
+ <span class="cline-any cline-neutral">&nbsp;</span>
807
+ <span class="cline-any cline-yes">22x</span>
808
+ <span class="cline-any cline-neutral">&nbsp;</span>
809
+ <span class="cline-any cline-yes">21x</span>
810
+ <span class="cline-any cline-neutral">&nbsp;</span>
811
+ <span class="cline-any cline-yes">21x</span>
812
+ <span class="cline-any cline-yes">41x</span>
813
+ <span class="cline-any cline-yes">2x</span>
814
+ <span class="cline-any cline-neutral">&nbsp;</span>
815
+ <span class="cline-any cline-neutral">&nbsp;</span>
816
+ <span class="cline-any cline-neutral">&nbsp;</span>
817
+ <span class="cline-any cline-yes">35x</span>
818
+ <span class="cline-any cline-neutral">&nbsp;</span>
819
+ <span class="cline-any cline-neutral">&nbsp;</span>
820
+ <span class="cline-any cline-yes">35x</span>
821
+ <span class="cline-any cline-yes">35x</span>
822
+ <span class="cline-any cline-yes">75x</span>
823
+ <span class="cline-any cline-neutral">&nbsp;</span>
824
+ <span class="cline-any cline-yes">75x</span>
825
+ <span class="cline-any cline-yes">62x</span>
826
+ <span class="cline-any cline-yes">62x</span>
827
+ <span class="cline-any cline-neutral">&nbsp;</span>
828
+ <span class="cline-any cline-neutral">&nbsp;</span>
829
+ <span class="cline-any cline-yes">13x</span>
830
+ <span class="cline-any cline-yes">13x</span>
831
+ <span class="cline-any cline-yes">5x</span>
832
+ <span class="cline-any cline-yes">2x</span>
833
+ <span class="cline-any cline-neutral">&nbsp;</span>
834
+ <span class="cline-any cline-neutral">&nbsp;</span>
835
+ <span class="cline-any cline-neutral">&nbsp;</span>
836
+ <span class="cline-any cline-yes">3x</span>
837
+ <span class="cline-any cline-yes">3x</span>
838
+ <span class="cline-any cline-yes">3x</span>
839
+ <span class="cline-any cline-yes">3x</span>
840
+ <span class="cline-any cline-yes">4x</span>
841
+ <span class="cline-any cline-yes">4x</span>
842
+ <span class="cline-any cline-yes">1x</span>
843
+ <span class="cline-any cline-neutral">&nbsp;</span>
844
+ <span class="cline-any cline-neutral">&nbsp;</span>
845
+ <span class="cline-any cline-neutral">&nbsp;</span>
846
+ <span class="cline-any cline-yes">5x</span>
847
+ <span class="cline-any cline-yes">5x</span>
848
+ <span class="cline-any cline-yes">5x</span>
849
+ <span class="cline-any cline-yes">3x</span>
850
+ <span class="cline-any cline-neutral">&nbsp;</span>
851
+ <span class="cline-any cline-yes">2x</span>
852
+ <span class="cline-any cline-yes">2x</span>
853
+ <span class="cline-any cline-yes">2x</span>
854
+ <span class="cline-any cline-neutral">&nbsp;</span>
855
+ <span class="cline-any cline-no">&nbsp;</span>
856
+ <span class="cline-any cline-neutral">&nbsp;</span>
857
+ <span class="cline-any cline-neutral">&nbsp;</span>
858
+ <span class="cline-any cline-yes">5x</span>
859
+ <span class="cline-any cline-neutral">&nbsp;</span>
860
+ <span class="cline-any cline-neutral">&nbsp;</span>
861
+ <span class="cline-any cline-neutral">&nbsp;</span>
862
+ <span class="cline-any cline-yes">13x</span>
863
+ <span class="cline-any cline-neutral">&nbsp;</span>
864
+ <span class="cline-any cline-yes">5x</span>
865
+ <span class="cline-any cline-neutral">&nbsp;</span>
866
+ <span class="cline-any cline-neutral">&nbsp;</span>
867
+ <span class="cline-any cline-yes">27x</span>
868
+ <span class="cline-any cline-neutral">&nbsp;</span>
869
+ <span class="cline-any cline-neutral">&nbsp;</span>
870
+ <span class="cline-any cline-neutral">&nbsp;</span>
871
+ <span class="cline-any cline-yes">24x</span>
872
+ <span class="cline-any cline-yes">24x</span>
873
+ <span class="cline-any cline-yes">24x</span>
874
+ <span class="cline-any cline-yes">24x</span>
875
+ <span class="cline-any cline-neutral">&nbsp;</span>
876
+ <span class="cline-any cline-neutral">&nbsp;</span>
877
+ <span class="cline-any cline-yes">24x</span>
878
+ <span class="cline-any cline-yes">47x</span>
879
+ <span class="cline-any cline-yes">19x</span>
880
+ <span class="cline-any cline-yes">19x</span>
881
+ <span class="cline-any cline-yes">1x</span>
882
+ <span class="cline-any cline-yes">1x</span>
883
+ <span class="cline-any cline-neutral">&nbsp;</span>
884
+ <span class="cline-any cline-neutral">&nbsp;</span>
885
+ <span class="cline-any cline-yes">19x</span>
886
+ <span class="cline-any cline-yes">19x</span>
887
+ <span class="cline-any cline-neutral">&nbsp;</span>
888
+ <span class="cline-any cline-yes">18x</span>
889
+ <span class="cline-any cline-neutral">&nbsp;</span>
890
+ <span class="cline-any cline-yes">17x</span>
891
+ <span class="cline-any cline-neutral">&nbsp;</span>
892
+ <span class="cline-any cline-neutral">&nbsp;</span>
893
+ <span class="cline-any cline-yes">28x</span>
894
+ <span class="cline-any cline-yes">28x</span>
895
+ <span class="cline-any cline-neutral">&nbsp;</span>
896
+ <span class="cline-any cline-neutral">&nbsp;</span>
897
+ <span class="cline-any cline-yes">28x</span>
898
+ <span class="cline-any cline-yes">30x</span>
899
+ <span class="cline-any cline-yes">30x</span>
900
+ <span class="cline-any cline-neutral">&nbsp;</span>
901
+ <span class="cline-any cline-yes">28x</span>
902
+ <span class="cline-any cline-yes">28x</span>
903
+ <span class="cline-any cline-neutral">&nbsp;</span>
904
+ <span class="cline-any cline-neutral">&nbsp;</span>
905
+ <span class="cline-any cline-neutral">&nbsp;</span>
906
+ <span class="cline-any cline-yes">20x</span>
907
+ <span class="cline-any cline-neutral">&nbsp;</span>
908
+ <span class="cline-any cline-neutral">&nbsp;</span>
909
+ <span class="cline-any cline-neutral">&nbsp;</span>
910
+ <span class="cline-any cline-neutral">&nbsp;</span>
911
+ <span class="cline-any cline-neutral">&nbsp;</span>
912
+ <span class="cline-any cline-neutral">&nbsp;</span>
913
+ <span class="cline-any cline-yes">44x</span>
914
+ <span class="cline-any cline-yes">14x</span>
915
+ <span class="cline-any cline-neutral">&nbsp;</span>
916
+ <span class="cline-any cline-neutral">&nbsp;</span>
917
+ <span class="cline-any cline-neutral">&nbsp;</span>
918
+ <span class="cline-any cline-yes">44x</span>
919
+ <span class="cline-any cline-neutral">&nbsp;</span>
920
+ <span class="cline-any cline-neutral">&nbsp;</span>
921
+ <span class="cline-any cline-neutral">&nbsp;</span>
922
+ <span class="cline-any cline-yes">4x</span>
923
+ <span class="cline-any cline-neutral">&nbsp;</span>
924
+ <span class="cline-any cline-yes">4x</span>
925
+ <span class="cline-any cline-yes">3x</span>
926
+ <span class="cline-any cline-neutral">&nbsp;</span>
927
+ <span class="cline-any cline-yes">3x</span>
928
+ <span class="cline-any cline-no">&nbsp;</span>
929
+ <span class="cline-any cline-no">&nbsp;</span>
930
+ <span class="cline-any cline-neutral">&nbsp;</span>
931
+ <span class="cline-any cline-neutral">&nbsp;</span>
932
+ <span class="cline-any cline-yes">3x</span>
933
+ <span class="cline-any cline-yes">3x</span>
934
+ <span class="cline-any cline-neutral">&nbsp;</span>
935
+ <span class="cline-any cline-neutral">&nbsp;</span>
936
+ <span class="cline-any cline-yes">3x</span>
937
+ <span class="cline-any cline-yes">4x</span>
938
+ <span class="cline-any cline-no">&nbsp;</span>
939
+ <span class="cline-any cline-neutral">&nbsp;</span>
940
+ <span class="cline-any cline-neutral">&nbsp;</span>
941
+ <span class="cline-any cline-yes">4x</span>
942
+ <span class="cline-any cline-neutral">&nbsp;</span>
943
+ <span class="cline-any cline-neutral">&nbsp;</span>
944
+ <span class="cline-any cline-neutral">&nbsp;</span>
945
+ <span class="cline-any cline-yes">24x</span>
946
+ <span class="cline-any cline-yes">24x</span>
947
+ <span class="cline-any cline-neutral">&nbsp;</span>
948
+ <span class="cline-any cline-neutral">&nbsp;</span>
949
+ <span class="cline-any cline-neutral">&nbsp;</span>
950
+ <span class="cline-any cline-neutral">&nbsp;</span>
951
+ <span class="cline-any cline-neutral">&nbsp;</span>
952
+ <span class="cline-any cline-neutral">&nbsp;</span>
953
+ <span class="cline-any cline-neutral">&nbsp;</span>
954
+ <span class="cline-any cline-yes">26x</span>
955
+ <span class="cline-any cline-yes">22x</span>
956
+ <span class="cline-any cline-neutral">&nbsp;</span>
957
+ <span class="cline-any cline-neutral">&nbsp;</span>
958
+ <span class="cline-any cline-yes">44x</span>
959
+ <span class="cline-any cline-neutral">&nbsp;</span>
960
+ <span class="cline-any cline-neutral">&nbsp;</span>
961
+ <span class="cline-any cline-neutral">&nbsp;</span>
962
+ <span class="cline-any cline-neutral">&nbsp;</span>
963
+ <span class="cline-any cline-neutral">&nbsp;</span>
964
+ <span class="cline-any cline-neutral">&nbsp;</span>
965
+ <span class="cline-any cline-neutral">&nbsp;</span>
966
+ <span class="cline-any cline-neutral">&nbsp;</span>
967
+ <span class="cline-any cline-neutral">&nbsp;</span>
968
+ <span class="cline-any cline-neutral">&nbsp;</span>
969
+ <span class="cline-any cline-neutral">&nbsp;</span>
970
+ <span class="cline-any cline-neutral">&nbsp;</span>
971
+ <span class="cline-any cline-no">&nbsp;</span>
972
+ <span class="cline-any cline-neutral">&nbsp;</span>
973
+ <span class="cline-any cline-no">&nbsp;</span>
974
+ <span class="cline-any cline-neutral">&nbsp;</span>
975
+ <span class="cline-any cline-neutral">&nbsp;</span>
976
+ <span class="cline-any cline-neutral">&nbsp;</span>
977
+ <span class="cline-any cline-no">&nbsp;</span>
978
+ <span class="cline-any cline-neutral">&nbsp;</span>
979
+ <span class="cline-any cline-no">&nbsp;</span>
980
+ <span class="cline-any cline-neutral">&nbsp;</span>
981
+ <span class="cline-any cline-neutral">&nbsp;</span>
982
+ <span class="cline-any cline-neutral">&nbsp;</span>
983
+ <span class="cline-any cline-neutral">&nbsp;</span>
984
+ <span class="cline-any cline-neutral">&nbsp;</span>
985
+ <span class="cline-any cline-neutral">&nbsp;</span>
986
+ <span class="cline-any cline-neutral">&nbsp;</span>
987
+ <span class="cline-any cline-neutral">&nbsp;</span>
988
+ <span class="cline-any cline-neutral">&nbsp;</span>
989
+ <span class="cline-any cline-neutral">&nbsp;</span>
990
+ <span class="cline-any cline-neutral">&nbsp;</span>
991
+ <span class="cline-any cline-neutral">&nbsp;</span>
992
+ <span class="cline-any cline-yes">3x</span>
993
+ <span class="cline-any cline-yes">3x</span>
994
+ <span class="cline-any cline-yes">3x</span>
995
+ <span class="cline-any cline-yes">3x</span>
996
+ <span class="cline-any cline-neutral">&nbsp;</span>
997
+ <span class="cline-any cline-yes">3x</span>
998
+ <span class="cline-any cline-yes">1x</span>
999
+ <span class="cline-any cline-yes">1x</span>
1000
+ <span class="cline-any cline-yes">1x</span>
1001
+ <span class="cline-any cline-neutral">&nbsp;</span>
1002
+ <span class="cline-any cline-neutral">&nbsp;</span>
1003
+ <span class="cline-any cline-yes">3x</span>
1004
+ <span class="cline-any cline-yes">3x</span>
1005
+ <span class="cline-any cline-yes">1x</span>
1006
+ <span class="cline-any cline-neutral">&nbsp;</span>
1007
+ <span class="cline-any cline-yes">2x</span>
1008
+ <span class="cline-any cline-neutral">&nbsp;</span>
1009
+ <span class="cline-any cline-yes">2x</span>
1010
+ <span class="cline-any cline-neutral">&nbsp;</span>
1011
+ <span class="cline-any cline-neutral">&nbsp;</span>
1012
+ <span class="cline-any cline-neutral">&nbsp;</span>
1013
+ <span class="cline-any cline-neutral">&nbsp;</span>
1014
+ <span class="cline-any cline-no">&nbsp;</span>
1015
+ <span class="cline-any cline-neutral">&nbsp;</span>
1016
+ <span class="cline-any cline-neutral">&nbsp;</span>
1017
+ <span class="cline-any cline-neutral">&nbsp;</span>
1018
+ <span class="cline-any cline-neutral">&nbsp;</span>
1019
+ <span class="cline-any cline-neutral">&nbsp;</span>
1020
+ <span class="cline-any cline-neutral">&nbsp;</span>
1021
+ <span class="cline-any cline-neutral">&nbsp;</span>
1022
+ <span class="cline-any cline-neutral">&nbsp;</span>
1023
+ <span class="cline-any cline-neutral">&nbsp;</span>
1024
+ <span class="cline-any cline-neutral">&nbsp;</span>
1025
+ <span class="cline-any cline-neutral">&nbsp;</span>
1026
+ <span class="cline-any cline-neutral">&nbsp;</span>
1027
+ <span class="cline-any cline-yes">1x</span>
1028
+ <span class="cline-any cline-yes">24x</span>
1029
+ <span class="cline-any cline-neutral">&nbsp;</span>
1030
+ <span class="cline-any cline-neutral">&nbsp;</span>
1031
+ <span class="cline-any cline-neutral">&nbsp;</span>
1032
+ <span class="cline-any cline-yes">5x</span>
1033
+ <span class="cline-any cline-yes">5x</span>
1034
+ <span class="cline-any cline-neutral">&nbsp;</span>
1035
+ <span class="cline-any cline-no">&nbsp;</span>
1036
+ <span class="cline-any cline-neutral">&nbsp;</span>
1037
+ <span class="cline-any cline-neutral">&nbsp;</span>
1038
+ <span class="cline-any cline-neutral">&nbsp;</span>
1039
+ <span class="cline-any cline-yes">1x</span>
1040
+ <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
1041
+ &nbsp;
1042
+ const
1043
+ UTIL = require('util'),
1044
+ PATH = require('path'),
1045
+ EOL = require('os').EOL,
1046
+ &nbsp;
1047
+ Q = require('q'),
1048
+ &nbsp;
1049
+ CoaObject = require('./coaobject'),
1050
+ Color = require('./color'),
1051
+ Opt = require('./opt'),
1052
+ Arg = require('./arg'),
1053
+ completion = require('./completion');
1054
+ &nbsp;
1055
+ /**
1056
+ * Command
1057
+ *
1058
+ * Top level entity. Commands may have options and arguments.
1059
+ *
1060
+ * @namespace
1061
+ * @class Cmd
1062
+ * @extends CoaObject
1063
+ */
1064
+ class Cmd extends CoaObject {
1065
+ /**
1066
+ * @constructs
1067
+ * @param {COA.Cmd} [cmd] parent command
1068
+ */
1069
+ constructor(cmd) {
1070
+ super(cmd);
1071
+ &nbsp;
1072
+ this._parent(cmd);
1073
+ this._cmds = [];
1074
+ this._cmdsByName = {};
1075
+ this._opts = [];
1076
+ this._optsByKey = {};
1077
+ this._args = [];
1078
+ this._api = null;
1079
+ this._ext = false;
1080
+ }
1081
+ &nbsp;
1082
+ static create(cmd) {
1083
+ return new Cmd(cmd);
1084
+ }
1085
+ &nbsp;
1086
+ /**
1087
+ * Returns object containing all its subcommands as methods
1088
+ * to use from other programs.
1089
+ *
1090
+ * @returns {Object}
1091
+ */
1092
+ get api() {
1093
+ // Need _this here because of passed arguments into _api
1094
+ const _this = this;
1095
+ this._api || (this._api = function () {
1096
+ return _this.invoke.apply(_this, arguments);
1097
+ });
1098
+ &nbsp;
1099
+ const cmds = this._cmdsByName;
1100
+ Object.keys(cmds).forEach((c) =&gt; {
1101
+ this._api[c] = cmds[c].api;
1102
+ });
1103
+ return this._api;
1104
+ }
1105
+ &nbsp;
1106
+ _parent(cmd) {
1107
+ this._cmd = cmd || this;
1108
+ &nbsp;
1109
+ this.isRootCmd
1110
+ || cmd._cmds.push(this)
1111
+ &amp;&amp; this._name
1112
+ &amp;&amp; (this._cmd._cmdsByName[this._name] = this);
1113
+ &nbsp;
1114
+ return this;
1115
+ }
1116
+ &nbsp;
1117
+ get isRootCmd() {
1118
+ return this._cmd === this;
1119
+ }
1120
+ &nbsp;
1121
+ /**
1122
+ * Set a canonical command identifier to be used anywhere in the API.
1123
+ *
1124
+ * @param {String} name - command name
1125
+ * @returns {COA.Cmd} - this instance (for chainability)
1126
+ */
1127
+ name(name) {
1128
+ super.name(name);
1129
+ &nbsp;
1130
+ this.isRootCmd
1131
+ || (this._cmd._cmdsByName[name] = this);
1132
+ &nbsp;
1133
+ return this;
1134
+ }
1135
+ &nbsp;
1136
+ /**
1137
+ * Create new or add existing subcommand for current command.
1138
+ *
1139
+ * @param {COA.Cmd} [cmd] existing command instance
1140
+ * @returns {COA.Cmd} new subcommand instance
1141
+ */
1142
+ cmd(cmd) {
1143
+ return cmd?
1144
+ cmd._parent(this)
1145
+ : new Cmd(this);
1146
+ }
1147
+ &nbsp;
1148
+ /**
1149
+ * Create option for current command.
1150
+ *
1151
+ * @returns {COA.Opt} new option instance
1152
+ */
1153
+ opt() {
1154
+ return new Opt(this);
1155
+ }
1156
+ &nbsp;
1157
+ /**
1158
+ * Create argument for current command.
1159
+ *
1160
+ * @returns {COA.Opt} new argument instance
1161
+ */
1162
+ arg() {
1163
+ return new Arg(this);
1164
+ }
1165
+ &nbsp;
1166
+ /**
1167
+ * Add (or set) action for current command.
1168
+ *
1169
+ * @param {Function} act - action function,
1170
+ * invoked in the context of command instance
1171
+ * and has the parameters:
1172
+ * - {Object} opts - parsed options
1173
+ * - {String[]} args - parsed arguments
1174
+ * - {Object} res - actions result accumulator
1175
+ * It can return rejected promise by Cmd.reject (in case of error)
1176
+ * or any other value treated as result.
1177
+ * @param {Boolean} [force=false] flag for set action instead add to existings
1178
+ * @returns {COA.Cmd} - this instance (for chainability)
1179
+ */
1180
+ act(act, force) {
1181
+ <span class="missing-if-branch" title="if path not taken" >I</span>if(!act) <span class="cstat-no" title="statement not covered" >return this;</span>
1182
+ &nbsp;
1183
+ (!this._act || <span class="branch-1 cbranch-no" title="branch not covered" >force)</span> &amp;&amp; (this._act = []);
1184
+ this._act.push(act);
1185
+ &nbsp;
1186
+ return this;
1187
+ }
1188
+ &nbsp;
1189
+ /**
1190
+ * Make command "helpful", i.e. add -h --help flags for print usage.
1191
+ *
1192
+ * @returns {COA.Cmd} - this instance (for chainability)
1193
+ */
1194
+ <span class="fstat-no" title="function not covered" > he</span>lpful() {
1195
+ <span class="cstat-no" title="statement not covered" > return this.opt()</span>
1196
+ .name('help')
1197
+ .title('Help')
1198
+ .short('h')
1199
+ .long('help')
1200
+ .flag()
1201
+ .only()
1202
+ .act(<span class="fstat-no" title="function not covered" >fu</span>nction() {
1203
+ <span class="cstat-no" title="statement not covered" > return this.usage();</span>
1204
+ })
1205
+ .end();
1206
+ }
1207
+ &nbsp;
1208
+ /**
1209
+ * Adds shell completion to command, adds "completion" subcommand,
1210
+ * that makes all the magic.
1211
+ * Must be called only on root command.
1212
+ *
1213
+ * @returns {COA.Cmd} - this instance (for chainability)
1214
+ */
1215
+ <span class="fstat-no" title="function not covered" > co</span>mpletable() {
1216
+ <span class="cstat-no" title="statement not covered" > return this.cmd()</span>
1217
+ .name('completion')
1218
+ .apply(completion)
1219
+ .end();
1220
+ }
1221
+ &nbsp;
1222
+ /**
1223
+ * Allow command to be extendable by external node.js modules.
1224
+ *
1225
+ * @param {String} [pattern] Pattern of node.js module to find subcommands at.
1226
+ * @returns {COA.Cmd} - this instance (for chainability)
1227
+ */
1228
+ extendable(pattern) {
1229
+ this._ext = pattern || true;
1230
+ return this;
1231
+ }
1232
+ &nbsp;
1233
+ <span class="fstat-no" title="function not covered" > _e</span>xit(msg, code) {
1234
+ <span class="cstat-no" title="statement not covered" > return process.once('exit', <span class="fstat-no" title="function not covered" >fu</span>nction() {</span>
1235
+ <span class="cstat-no" title="statement not covered" > msg &amp;&amp; console.error(msg);</span>
1236
+ <span class="cstat-no" title="statement not covered" > return process.exit(code || 0);</span>
1237
+ });
1238
+ }
1239
+ &nbsp;
1240
+ /**
1241
+ * Build full usage text for current command instance.
1242
+ *
1243
+ * @returns {String} usage text
1244
+ */
1245
+ <span class="fstat-no" title="function not covered" > us</span>age() {
1246
+ const res = <span class="cstat-no" title="statement not covered" >[];</span>
1247
+ &nbsp;
1248
+ <span class="cstat-no" title="statement not covered" > this._title &amp;&amp; res.push(this._fullTitle());</span>
1249
+ &nbsp;
1250
+ <span class="cstat-no" title="statement not covered" > res.push('', 'Usage:');</span>
1251
+ &nbsp;
1252
+ <span class="cstat-no" title="statement not covered" > this._cmds.length</span>
1253
+ &amp;&amp; res.push([
1254
+ '', '', Color('lred', this._fullName()), Color('lblue', 'COMMAND'),
1255
+ Color('lgreen', '[OPTIONS]'), Color('lpurple', '[ARGS]')
1256
+ ].join(' '));
1257
+ &nbsp;
1258
+ <span class="cstat-no" title="statement not covered" > (this._opts.length + this._args.length)</span>
1259
+ &amp;&amp; res.push([
1260
+ '', '', Color('lred', this._fullName()),
1261
+ Color('lgreen', '[OPTIONS]'), Color('lpurple', '[ARGS]')
1262
+ ].join(' '));
1263
+ &nbsp;
1264
+ <span class="cstat-no" title="statement not covered" > res.push(</span>
1265
+ this._usages(this._cmds, 'Commands'),
1266
+ this._usages(this._opts, 'Options'),
1267
+ this._usages(this._args, 'Arguments')
1268
+ );
1269
+ &nbsp;
1270
+ <span class="cstat-no" title="statement not covered" > return res.join(EOL);</span>
1271
+ }
1272
+ &nbsp;
1273
+ <span class="fstat-no" title="function not covered" > _u</span>sage() {
1274
+ <span class="cstat-no" title="statement not covered" > return Color('lblue', this._name) + ' : ' + this._title;</span>
1275
+ }
1276
+ &nbsp;
1277
+ <span class="fstat-no" title="function not covered" > _u</span>sages(os, title) {
1278
+ <span class="cstat-no" title="statement not covered" > if(!os.length) <span class="cstat-no" title="statement not covered" >return;</span></span>
1279
+ &nbsp;
1280
+ <span class="cstat-no" title="statement not covered" > return ['', title + ':']</span>
1281
+ .concat(os.map(<span class="fstat-no" title="function not covered" >o </span>=&gt; <span class="cstat-no" title="statement not covered" >` ${o._usage()}`)</span>)
1282
+ .join(EOL);
1283
+ }
1284
+ &nbsp;
1285
+ <span class="fstat-no" title="function not covered" > _f</span>ullTitle() {
1286
+ <span class="cstat-no" title="statement not covered" > return `${this.isRootCmd? '' : this._cmd._fullTitle() + EOL}${this._title}`;</span>
1287
+ }
1288
+ &nbsp;
1289
+ <span class="fstat-no" title="function not covered" > _f</span>ullName() {
1290
+ <span class="cstat-no" title="statement not covered" > return `${this.isRootCmd? '' : this._cmd._fullName() + ' '}${PATH.basename(this._name)}`;</span>
1291
+ }
1292
+ &nbsp;
1293
+ _ejectOpt(opts, opt) {
1294
+ const pos = opts.indexOf(opt);
1295
+ if(pos === -1)
1296
+ return;
1297
+ &nbsp;
1298
+ return opts[pos]._arr?
1299
+ opts[pos]
1300
+ : opts.splice(pos, 1)[0];
1301
+ }
1302
+ &nbsp;
1303
+ _checkRequired(opts, args) {
1304
+ if(this._opts.some(opt =&gt; opt._only &amp;&amp; opt._name in opts)) return;
1305
+ &nbsp;
1306
+ const all = this._opts.concat(this._args);
1307
+ let i;
1308
+ while(i = all.shift())
1309
+ if(i._req &amp;&amp; i._checkParsed(opts, args))
1310
+ return this.reject(i._requiredText());
1311
+ }
1312
+ &nbsp;
1313
+ _parseCmd(argv, unparsed) {
1314
+ unparsed || (unparsed = []);
1315
+ &nbsp;
1316
+ let i,
1317
+ optSeen = false;
1318
+ while(i = argv.shift()) {
1319
+ i.indexOf('-') || (optSeen = true);
1320
+ &nbsp;
1321
+ if(optSeen || !/^\w[\w-_]*$/.test(i)) {
1322
+ unparsed.push(i);
1323
+ continue;
1324
+ }
1325
+ &nbsp;
1326
+ let pkg, cmd = this._cmdsByName[i];
1327
+ if(!cmd &amp;&amp; this._ext) {
1328
+ if(typeof this._ext === 'string') {
1329
+ pkg = ~this._ext.indexOf('%s')?
1330
+ UTIL.format(this._ext, i)
1331
+ : this._ext + i;
1332
+ &nbsp;
1333
+ } else <span class="missing-if-branch" title="else path not taken" >E</span>if(this._ext === true) {
1334
+ pkg = i;
1335
+ let c = this;
1336
+ while(true) { // eslint-disable-line
1337
+ pkg = c._name + '-' + pkg;
1338
+ if(c.isRootCmd) break;
1339
+ c = c._cmd;
1340
+ }
1341
+ }
1342
+ &nbsp;
1343
+ const cmdDesc = tryCatch(() =&gt; require(pkg));
1344
+ <span class="missing-if-branch" title="else path not taken" >E</span>if(cmdDesc) {
1345
+ if(typeof cmdDesc === 'function') {
1346
+ this.cmd().name(i).apply(cmdDesc).end();
1347
+ &nbsp;
1348
+ } else <span class="missing-if-branch" title="else path not taken" >E</span>if(typeof cmdDesc === 'object') {
1349
+ this.cmd(cmdDesc);
1350
+ cmdDesc.name(i);
1351
+ &nbsp;
1352
+ } else <span class="cstat-no" title="statement not covered" >throw new Error('Error: Unsupported command declaration type, '</span>
1353
+ + 'should be a function or COA.Cmd() object');
1354
+ &nbsp;
1355
+ cmd = this._cmdsByName[i];
1356
+ }
1357
+ }
1358
+ &nbsp;
1359
+ if(cmd) return cmd._parseCmd(argv, unparsed);
1360
+ &nbsp;
1361
+ unparsed.push(i);
1362
+ }
1363
+ &nbsp;
1364
+ return { cmd : this, argv : unparsed };
1365
+ }
1366
+ &nbsp;
1367
+ _parseOptsAndArgs(argv) {
1368
+ const opts = {},
1369
+ args = {},
1370
+ nonParsedOpts = this._opts.concat(),
1371
+ nonParsedArgs = this._args.concat();
1372
+ &nbsp;
1373
+ let res, i;
1374
+ while(i = argv.shift()) {
1375
+ if(i !== '--' &amp;&amp; i[0] === '-') {
1376
+ const m = i.match(/^(--\w[\w-_]*)=(.*)$/);
1377
+ if(m) {
1378
+ i = m[1];
1379
+ this._optsByKey[i]._flag || argv.unshift(m[2]);
1380
+ }
1381
+ &nbsp;
1382
+ const opt = this._ejectOpt(nonParsedOpts, this._optsByKey[i]);
1383
+ if(!opt) return this.reject(`Unknown option: ${i}`);
1384
+ &nbsp;
1385
+ if(Q.isRejected(res = opt._parse(argv, opts))) return res;
1386
+ &nbsp;
1387
+ continue;
1388
+ }
1389
+ &nbsp;
1390
+ i === '--' &amp;&amp; (i = argv.splice(0));
1391
+ Array.isArray(i) || (i = [i]);
1392
+ &nbsp;
1393
+ let a;
1394
+ while(a = i.shift()) {
1395
+ let arg = nonParsedArgs.shift();
1396
+ if(!arg) return this.reject(`Unknown argument: ${a}`);
1397
+ &nbsp;
1398
+ arg._arr &amp;&amp; nonParsedArgs.unshift(arg);
1399
+ <span class="missing-if-branch" title="if path not taken" >I</span>if(Q.isRejected(res = arg._parse(a, args))) <span class="cstat-no" title="statement not covered" >return res;</span>
1400
+ }
1401
+ }
1402
+ &nbsp;
1403
+ return {
1404
+ opts : this._setDefaults(opts, nonParsedOpts),
1405
+ args : this._setDefaults(args, nonParsedArgs)
1406
+ };
1407
+ }
1408
+ &nbsp;
1409
+ _setDefaults(params, desc) {
1410
+ for(const item of desc)
1411
+ item._def
1412
+ &amp;&amp; !(item._name in params)
1413
+ &amp;&amp; item._saveVal(params, item._def);
1414
+ &nbsp;
1415
+ return params;
1416
+ }
1417
+ &nbsp;
1418
+ _processParams(params, desc) {
1419
+ const notExists = [];
1420
+ &nbsp;
1421
+ for(const item of desc) {
1422
+ const n = item._name;
1423
+ &nbsp;
1424
+ <span class="missing-if-branch" title="if path not taken" >I</span>if(!(n in params)) {
1425
+ <span class="cstat-no" title="statement not covered" > notExists.push(item);</span>
1426
+ <span class="cstat-no" title="statement not covered" > continue;</span>
1427
+ }
1428
+ &nbsp;
1429
+ const vals = [].concat(params[n]);
1430
+ delete params[n];
1431
+ &nbsp;
1432
+ let res;
1433
+ for(const v of vals)
1434
+ <span class="missing-if-branch" title="if path not taken" >I</span>if(Q.isRejected(res = item._saveVal(params, v)))
1435
+ <span class="cstat-no" title="statement not covered" > return res;</span>
1436
+ }
1437
+ &nbsp;
1438
+ return this._setDefaults(params, notExists);
1439
+ }
1440
+ &nbsp;
1441
+ _parseArr(argv) {
1442
+ return Q.when(this._parseCmd(argv), (p) =&gt;
1443
+ Q.when(p.cmd._parseOptsAndArgs(p.argv), (r) =&gt; ({
1444
+ cmd : p.cmd,
1445
+ opts : r.opts,
1446
+ args : r.args
1447
+ })));
1448
+ }
1449
+ &nbsp;
1450
+ _do(inputPromise) {
1451
+ return Q.when(inputPromise, (input) =&gt; {
1452
+ return [this._checkRequired]
1453
+ .concat(input.cmd._act || <span class="branch-1 cbranch-no" title="branch not covered" >[])</span>
1454
+ .reduce((res, act) =&gt;
1455
+ Q.when(res, (prev) =&gt; act.call(input.cmd, input.opts, input.args, prev)),
1456
+ void 0);
1457
+ });
1458
+ }
1459
+ &nbsp;
1460
+ /**
1461
+ * Parse arguments from simple format like NodeJS process.argv
1462
+ * and run ahead current program, i.e. call process.exit when all actions done.
1463
+ *
1464
+ * @param {String[]} argv - arguments
1465
+ * @returns {COA.Cmd} - this instance (for chainability)
1466
+ */
1467
+ <span class="fstat-no" title="function not covered" > ru</span>n(argv) {
1468
+ <span class="cstat-no" title="statement not covered" > argv || (argv = process.argv.slice(2));</span>
1469
+ &nbsp;
1470
+ const cb = <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >(c</span>ode) =&gt; <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >(r</span>es) =&gt; <span class="cstat-no" title="statement not covered" >res?</span></span></span>
1471
+ this._exit(res.stack || res.toString(), res.exitCode || code)
1472
+ : this._exit();
1473
+ &nbsp;
1474
+ <span class="cstat-no" title="statement not covered" > Q.when(this.do(argv), cb(0), cb(1)).done();</span>
1475
+ &nbsp;
1476
+ <span class="cstat-no" title="statement not covered" > return this;</span>
1477
+ }
1478
+ &nbsp;
1479
+ /**
1480
+ * Invoke specified (or current) command using provided
1481
+ * options and arguments.
1482
+ *
1483
+ * @param {String|String[]} [cmds] - subcommand to invoke (optional)
1484
+ * @param {Object} [opts] - command options (optional)
1485
+ * @param {Object} [args] - command arguments (optional)
1486
+ * @returns {Q.Promise}
1487
+ */
1488
+ invoke(cmds, opts, args) {
1489
+ cmds || (<span class="branch-1 cbranch-no" title="branch not covered" >cmds = [])</span>;
1490
+ opts || (opts = {});
1491
+ args || (args = {});
1492
+ typeof cmds === 'string' &amp;&amp; (cmds = cmds.split(' '));
1493
+ &nbsp;
1494
+ if(arguments.length &lt; 3 &amp;&amp; !Array.isArray(cmds)) {
1495
+ args = opts;
1496
+ opts = cmds;
1497
+ cmds = [];
1498
+ }
1499
+ &nbsp;
1500
+ return Q.when(this._parseCmd(cmds), (p) =&gt; {
1501
+ if(p.argv.length)
1502
+ return this.reject(`Unknown command: ${cmds.join(' ')}`);
1503
+ &nbsp;
1504
+ return Q.all([this._processParams(opts, this._opts), this._processParams(args, this._args)])
1505
+ .spread((_opts, _args) =&gt;
1506
+ this._do({
1507
+ cmd : p.cmd,
1508
+ opts : _opts,
1509
+ args : _args
1510
+ })
1511
+ .fail(<span class="fstat-no" title="function not covered" >(r</span>es) =&gt; <span class="cstat-no" title="statement not covered" >(res &amp;&amp; res.exitCode === 0)?</span>
1512
+ res.toString()
1513
+ : this.reject(res)));
1514
+ });
1515
+ }
1516
+ }
1517
+ &nbsp;
1518
+ /**
1519
+ * Convenient function to run command from tests.
1520
+ *
1521
+ * @param {String[]} argv - arguments
1522
+ * @returns {Q.Promise}
1523
+ */
1524
+ Cmd.prototype.do = function(argv) {
1525
+ return this._do(this._parseArr(argv || []));
1526
+ };
1527
+ &nbsp;
1528
+ function tryCatch(fn, cb) {
1529
+ try {
1530
+ return fn();
1531
+ } catch(e) {
1532
+ <span class="cstat-no" title="statement not covered" > return cb(e);</span>
1533
+ }
1534
+ }
1535
+ &nbsp;
1536
+ module.exports = Cmd;
1537
+ &nbsp;</pre></td></tr>
1538
+ </table></pre>
1539
+ <div class='push'></div><!-- for sticky footer -->
1540
+ </div><!-- /wrapper -->
1541
+ <div class='footer quiet pad2 space-top1 center small'>
1542
+ Code coverage
1543
+ generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
1544
+ </div>
1545
+ </div>
1546
+ <script src="../../prettify.js"></script>
1547
+ <script>
1548
+ window.onload = function () {
1549
+ if (typeof prettyPrint === 'function') {
1550
+ prettyPrint();
1551
+ }
1552
+ };
1553
+ </script>
1554
+ <script src="../../sorter.js"></script>
1555
+ </body>
1556
+ </html>