From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/coa/.npmignore | 6 + .../1f2a0db5a6d6559149db56d397f47cfc.json | 1 + .../75b82d38f2186df930141082076e11c6.json | 1 + node_modules/coa/.travis.yml | 9 + node_modules/coa/GNUmakefile | 34 + node_modules/coa/README.md | 322 ++++ node_modules/coa/README.ru.md | 316 ++++ node_modules/coa/coverage/base.css | 212 +++ node_modules/coa/coverage/coa/index.html | 93 ++ node_modules/coa/coverage/coa/index.js.html | 68 + node_modules/coa/coverage/coa/lib/arg.js.html | 239 +++ node_modules/coa/coverage/coa/lib/cmd.js.html | 1556 ++++++++++++++++++++ .../coa/coverage/coa/lib/coaobject.js.html | 365 +++++ node_modules/coa/coverage/coa/lib/coaparam.js.html | 440 ++++++ node_modules/coa/coverage/coa/lib/color.js.html | 131 ++ .../coa/coverage/coa/lib/completion.js.html | 593 ++++++++ node_modules/coa/coverage/coa/lib/index.html | 197 +++ node_modules/coa/coverage/coa/lib/index.js.html | 107 ++ node_modules/coa/coverage/coa/lib/opt.js.html | 524 +++++++ node_modules/coa/coverage/coa/lib/shell.js.html | 107 ++ node_modules/coa/coverage/index.html | 106 ++ node_modules/coa/coverage/prettify.css | 1 + node_modules/coa/coverage/prettify.js | 1 + node_modules/coa/coverage/sort-arrow-sprite.png | Bin 0 -> 209 bytes node_modules/coa/coverage/sorter.js | 158 ++ node_modules/coa/index.js | 1 + node_modules/coa/lib/arg.js | 175 +++ node_modules/coa/lib/cmd.js | 605 ++++++++ node_modules/coa/lib/color.js | 25 + node_modules/coa/lib/completion.js | 134 ++ node_modules/coa/lib/completion.sh | 43 + node_modules/coa/lib/index.js | 10 + node_modules/coa/lib/opt.js | 338 +++++ node_modules/coa/lib/shell.js | 14 + node_modules/coa/package.json | 44 + node_modules/coa/qq.js | 17 + node_modules/coa/src/arg.coffee | 130 ++ node_modules/coa/src/cmd.coffee | 456 ++++++ node_modules/coa/src/color.coffee | 25 + node_modules/coa/src/completion.coffee | 156 ++ node_modules/coa/src/index.coffee | 5 + node_modules/coa/src/opt.coffee | 243 +++ node_modules/coa/src/shell.coffee | 10 + node_modules/coa/test/coa.js | 496 +++++++ node_modules/coa/test/mocha.opts | 2 + node_modules/coa/test/shell-test.js | 60 + node_modules/coa/tests/api-h.js | 9 + node_modules/coa/tests/h.js | 6 + 48 files changed, 8591 insertions(+) create mode 100644 node_modules/coa/.npmignore create mode 100644 node_modules/coa/.nyc_output/1f2a0db5a6d6559149db56d397f47cfc.json create mode 100644 node_modules/coa/.nyc_output/75b82d38f2186df930141082076e11c6.json create mode 100644 node_modules/coa/.travis.yml create mode 100644 node_modules/coa/GNUmakefile create mode 100644 node_modules/coa/README.md create mode 100644 node_modules/coa/README.ru.md create mode 100644 node_modules/coa/coverage/base.css create mode 100644 node_modules/coa/coverage/coa/index.html create mode 100644 node_modules/coa/coverage/coa/index.js.html create mode 100644 node_modules/coa/coverage/coa/lib/arg.js.html create mode 100644 node_modules/coa/coverage/coa/lib/cmd.js.html create mode 100644 node_modules/coa/coverage/coa/lib/coaobject.js.html create mode 100644 node_modules/coa/coverage/coa/lib/coaparam.js.html create mode 100644 node_modules/coa/coverage/coa/lib/color.js.html create mode 100644 node_modules/coa/coverage/coa/lib/completion.js.html create mode 100644 node_modules/coa/coverage/coa/lib/index.html create mode 100644 node_modules/coa/coverage/coa/lib/index.js.html create mode 100644 node_modules/coa/coverage/coa/lib/opt.js.html create mode 100644 node_modules/coa/coverage/coa/lib/shell.js.html create mode 100644 node_modules/coa/coverage/index.html create mode 100644 node_modules/coa/coverage/prettify.css create mode 100644 node_modules/coa/coverage/prettify.js create mode 100644 node_modules/coa/coverage/sort-arrow-sprite.png create mode 100644 node_modules/coa/coverage/sorter.js create mode 100644 node_modules/coa/index.js create mode 100644 node_modules/coa/lib/arg.js create mode 100644 node_modules/coa/lib/cmd.js create mode 100644 node_modules/coa/lib/color.js create mode 100644 node_modules/coa/lib/completion.js create mode 100644 node_modules/coa/lib/completion.sh create mode 100644 node_modules/coa/lib/index.js create mode 100644 node_modules/coa/lib/opt.js create mode 100644 node_modules/coa/lib/shell.js create mode 100644 node_modules/coa/package.json create mode 100644 node_modules/coa/qq.js create mode 100644 node_modules/coa/src/arg.coffee create mode 100644 node_modules/coa/src/cmd.coffee create mode 100644 node_modules/coa/src/color.coffee create mode 100644 node_modules/coa/src/completion.coffee create mode 100644 node_modules/coa/src/index.coffee create mode 100644 node_modules/coa/src/opt.coffee create mode 100644 node_modules/coa/src/shell.coffee create mode 100644 node_modules/coa/test/coa.js create mode 100644 node_modules/coa/test/mocha.opts create mode 100644 node_modules/coa/test/shell-test.js create mode 100644 node_modules/coa/tests/api-h.js create mode 100644 node_modules/coa/tests/h.js (limited to 'node_modules/coa') diff --git a/node_modules/coa/.npmignore b/node_modules/coa/.npmignore new file mode 100644 index 00000000..7d47fc04 --- /dev/null +++ b/node_modules/coa/.npmignore @@ -0,0 +1,6 @@ +.idea +*.iml +node_modules/ +!node_modules/coa*.js +lib-cov/ +html-report/ diff --git a/node_modules/coa/.nyc_output/1f2a0db5a6d6559149db56d397f47cfc.json b/node_modules/coa/.nyc_output/1f2a0db5a6d6559149db56d397f47cfc.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/node_modules/coa/.nyc_output/1f2a0db5a6d6559149db56d397f47cfc.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/node_modules/coa/.nyc_output/75b82d38f2186df930141082076e11c6.json b/node_modules/coa/.nyc_output/75b82d38f2186df930141082076e11c6.json new file mode 100644 index 00000000..c7b8b0d7 --- /dev/null +++ b/node_modules/coa/.nyc_output/75b82d38f2186df930141082076e11c6.json @@ -0,0 +1 @@ +{"/Users/qfox/free/coa/index.js":{"path":"/Users/qfox/free/coa/index.js","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":34}}},"fnMap":{},"branchMap":{},"s":{"0":1},"f":{},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"b333994b2fa1659a2b5a38503a3ed9bee2f28966","contentHash":"2a1a6791db20994d7108d2f31184a5ff_10.3.2"},"/Users/qfox/free/coa/lib/index.js":{"path":"/Users/qfox/free/coa/lib/index.js","statementMap":{"0":{"start":{"line":2,"column":10},"end":{"line":2,"column":26}},"1":{"start":{"line":3,"column":10},"end":{"line":3,"column":26}},"2":{"start":{"line":4,"column":10},"end":{"line":4,"column":26}},"3":{"start":{"line":5,"column":12},"end":{"line":5,"column":30}},"4":{"start":{"line":7,"column":0},"end":{"line":14,"column":2}}},"fnMap":{},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1},"f":{},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"72030fb376bb695fb85d992545a6000ed4d912b8","contentHash":"fa38b2788afb9e8c1e417e263ee2a2b7_10.3.2"},"/Users/qfox/free/coa/lib/cmd.js":{"path":"/Users/qfox/free/coa/lib/cmd.js","statementMap":{"0":{"start":{"line":4,"column":11},"end":{"line":4,"column":26}},"1":{"start":{"line":5,"column":11},"end":{"line":5,"column":26}},"2":{"start":{"line":6,"column":10},"end":{"line":6,"column":27}},"3":{"start":{"line":8,"column":8},"end":{"line":8,"column":20}},"4":{"start":{"line":10,"column":16},"end":{"line":10,"column":38}},"5":{"start":{"line":11,"column":12},"end":{"line":11,"column":30}},"6":{"start":{"line":12,"column":10},"end":{"line":12,"column":26}},"7":{"start":{"line":13,"column":10},"end":{"line":13,"column":26}},"8":{"start":{"line":14,"column":17},"end":{"line":14,"column":40}},"9":{"start":{"line":31,"column":8},"end":{"line":31,"column":19}},"10":{"start":{"line":33,"column":8},"end":{"line":33,"column":26}},"11":{"start":{"line":34,"column":8},"end":{"line":34,"column":24}},"12":{"start":{"line":35,"column":8},"end":{"line":35,"column":30}},"13":{"start":{"line":36,"column":8},"end":{"line":36,"column":24}},"14":{"start":{"line":37,"column":8},"end":{"line":37,"column":29}},"15":{"start":{"line":38,"column":8},"end":{"line":38,"column":24}},"16":{"start":{"line":39,"column":8},"end":{"line":39,"column":25}},"17":{"start":{"line":40,"column":8},"end":{"line":40,"column":26}},"18":{"start":{"line":44,"column":8},"end":{"line":44,"column":28}},"19":{"start":{"line":55,"column":22},"end":{"line":55,"column":26}},"20":{"start":{"line":56,"column":8},"end":{"line":58,"column":11}},"21":{"start":{"line":57,"column":12},"end":{"line":57,"column":56}},"22":{"start":{"line":60,"column":21},"end":{"line":60,"column":37}},"23":{"start":{"line":61,"column":8},"end":{"line":61,"column":78}},"24":{"start":{"line":61,"column":43},"end":{"line":61,"column":74}},"25":{"start":{"line":63,"column":8},"end":{"line":63,"column":25}},"26":{"start":{"line":67,"column":8},"end":{"line":67,"column":32}},"27":{"start":{"line":69,"column":8},"end":{"line":72,"column":55}},"28":{"start":{"line":74,"column":8},"end":{"line":74,"column":20}},"29":{"start":{"line":78,"column":8},"end":{"line":78,"column":34}},"30":{"start":{"line":88,"column":8},"end":{"line":88,"column":25}},"31":{"start":{"line":90,"column":8},"end":{"line":91,"column":49}},"32":{"start":{"line":93,"column":8},"end":{"line":93,"column":20}},"33":{"start":{"line":103,"column":8},"end":{"line":105,"column":28}},"34":{"start":{"line":114,"column":8},"end":{"line":114,"column":29}},"35":{"start":{"line":123,"column":8},"end":{"line":123,"column":29}},"36":{"start":{"line":141,"column":8},"end":{"line":141,"column":29}},"37":{"start":{"line":141,"column":17},"end":{"line":141,"column":29}},"38":{"start":{"line":143,"column":8},"end":{"line":143,"column":50}},"39":{"start":{"line":144,"column":8},"end":{"line":144,"column":28}},"40":{"start":{"line":146,"column":8},"end":{"line":146,"column":20}},"41":{"start":{"line":155,"column":8},"end":{"line":165,"column":19}},"42":{"start":{"line":163,"column":16},"end":{"line":163,"column":36}},"43":{"start":{"line":176,"column":8},"end":{"line":179,"column":19}},"44":{"start":{"line":189,"column":8},"end":{"line":189,"column":36}},"45":{"start":{"line":190,"column":8},"end":{"line":190,"column":20}},"46":{"start":{"line":194,"column":8},"end":{"line":197,"column":11}},"47":{"start":{"line":195,"column":12},"end":{"line":195,"column":62}},"48":{"start":{"line":196,"column":12},"end":{"line":196,"column":36}},"49":{"start":{"line":206,"column":20},"end":{"line":206,"column":22}},"50":{"start":{"line":208,"column":8},"end":{"line":208,"column":51}},"51":{"start":{"line":210,"column":8},"end":{"line":210,"column":31}},"52":{"start":{"line":212,"column":8},"end":{"line":216,"column":25}},"53":{"start":{"line":218,"column":8},"end":{"line":222,"column":25}},"54":{"start":{"line":224,"column":8},"end":{"line":228,"column":10}},"55":{"start":{"line":230,"column":8},"end":{"line":230,"column":29}},"56":{"start":{"line":234,"column":8},"end":{"line":234,"column":64}},"57":{"start":{"line":238,"column":8},"end":{"line":238,"column":30}},"58":{"start":{"line":238,"column":23},"end":{"line":238,"column":30}},"59":{"start":{"line":240,"column":8},"end":{"line":242,"column":23}},"60":{"start":{"line":241,"column":32},"end":{"line":241,"column":49}},"61":{"start":{"line":246,"column":8},"end":{"line":246,"column":84}},"62":{"start":{"line":250,"column":8},"end":{"line":250,"column":97}},"63":{"start":{"line":254,"column":20},"end":{"line":254,"column":37}},"64":{"start":{"line":255,"column":8},"end":{"line":255,"column":30}},"65":{"start":{"line":255,"column":23},"end":{"line":255,"column":30}},"66":{"start":{"line":257,"column":8},"end":{"line":259,"column":35}},"67":{"start":{"line":263,"column":8},"end":{"line":263,"column":87}},"68":{"start":{"line":263,"column":34},"end":{"line":263,"column":77}},"69":{"start":{"line":263,"column":80},"end":{"line":263,"column":87}},"70":{"start":{"line":265,"column":20},"end":{"line":265,"column":49}},"71":{"start":{"line":267,"column":8},"end":{"line":269,"column":54}},"72":{"start":{"line":268,"column":12},"end":{"line":269,"column":54}},"73":{"start":{"line":269,"column":16},"end":{"line":269,"column":54}},"74":{"start":{"line":273,"column":8},"end":{"line":273,"column":36}},"75":{"start":{"line":276,"column":22},"end":{"line":276,"column":27}},"76":{"start":{"line":277,"column":8},"end":{"line":323,"column":9}},"77":{"start":{"line":278,"column":12},"end":{"line":278,"column":47}},"78":{"start":{"line":280,"column":12},"end":{"line":283,"column":13}},"79":{"start":{"line":281,"column":16},"end":{"line":281,"column":33}},"80":{"start":{"line":282,"column":16},"end":{"line":282,"column":25}},"81":{"start":{"line":285,"column":27},"end":{"line":285,"column":46}},"82":{"start":{"line":286,"column":12},"end":{"line":318,"column":13}},"83":{"start":{"line":287,"column":16},"end":{"line":298,"column":38}},"84":{"start":{"line":288,"column":20},"end":{"line":288,"column":28}},"85":{"start":{"line":289,"column":28},"end":{"line":289,"column":32}},"86":{"start":{"line":290,"column":20},"end":{"line":294,"column":21}},"87":{"start":{"line":291,"column":24},"end":{"line":291,"column":50}},"88":{"start":{"line":292,"column":24},"end":{"line":292,"column":46}},"89":{"start":{"line":292,"column":40},"end":{"line":292,"column":46}},"90":{"start":{"line":293,"column":24},"end":{"line":293,"column":35}},"91":{"start":{"line":295,"column":23},"end":{"line":298,"column":38}},"92":{"start":{"line":296,"column":20},"end":{"line":298,"column":38}},"93":{"start":{"line":301,"column":16},"end":{"line":305,"column":17}},"94":{"start":{"line":302,"column":20},"end":{"line":302,"column":43}},"95":{"start":{"line":307,"column":16},"end":{"line":317,"column":17}},"96":{"start":{"line":308,"column":20},"end":{"line":314,"column":70}},"97":{"start":{"line":309,"column":24},"end":{"line":309,"column":64}},"98":{"start":{"line":310,"column":27},"end":{"line":314,"column":70}},"99":{"start":{"line":311,"column":24},"end":{"line":311,"column":42}},"100":{"start":{"line":312,"column":24},"end":{"line":312,"column":40}},"101":{"start":{"line":313,"column":27},"end":{"line":314,"column":70}},"102":{"start":{"line":316,"column":20},"end":{"line":316,"column":46}},"103":{"start":{"line":320,"column":12},"end":{"line":320,"column":57}},"104":{"start":{"line":320,"column":20},"end":{"line":320,"column":57}},"105":{"start":{"line":322,"column":12},"end":{"line":322,"column":29}},"106":{"start":{"line":325,"column":8},"end":{"line":325,"column":47}},"107":{"start":{"line":329,"column":21},"end":{"line":329,"column":23}},"108":{"start":{"line":330,"column":19},"end":{"line":330,"column":21}},"109":{"start":{"line":331,"column":28},"end":{"line":331,"column":47}},"110":{"start":{"line":332,"column":28},"end":{"line":332,"column":47}},"111":{"start":{"line":335,"column":8},"end":{"line":362,"column":9}},"112":{"start":{"line":336,"column":12},"end":{"line":349,"column":13}},"113":{"start":{"line":337,"column":26},"end":{"line":337,"column":57}},"114":{"start":{"line":338,"column":16},"end":{"line":341,"column":17}},"115":{"start":{"line":339,"column":20},"end":{"line":339,"column":29}},"116":{"start":{"line":340,"column":20},"end":{"line":340,"column":67}},"117":{"start":{"line":343,"column":28},"end":{"line":343,"column":77}},"118":{"start":{"line":344,"column":16},"end":{"line":344,"column":68}},"119":{"start":{"line":344,"column":25},"end":{"line":344,"column":68}},"120":{"start":{"line":346,"column":16},"end":{"line":346,"column":74}},"121":{"start":{"line":346,"column":63},"end":{"line":346,"column":74}},"122":{"start":{"line":348,"column":16},"end":{"line":348,"column":25}},"123":{"start":{"line":351,"column":12},"end":{"line":351,"column":47}},"124":{"start":{"line":352,"column":12},"end":{"line":352,"column":42}},"125":{"start":{"line":355,"column":12},"end":{"line":361,"column":13}},"126":{"start":{"line":356,"column":26},"end":{"line":356,"column":47}},"127":{"start":{"line":357,"column":16},"end":{"line":357,"column":70}},"128":{"start":{"line":357,"column":25},"end":{"line":357,"column":70}},"129":{"start":{"line":359,"column":16},"end":{"line":359,"column":55}},"130":{"start":{"line":360,"column":16},"end":{"line":360,"column":71}},"131":{"start":{"line":360,"column":60},"end":{"line":360,"column":71}},"132":{"start":{"line":364,"column":8},"end":{"line":367,"column":10}},"133":{"start":{"line":371,"column":8},"end":{"line":374,"column":49}},"134":{"start":{"line":372,"column":12},"end":{"line":374,"column":49}},"135":{"start":{"line":376,"column":8},"end":{"line":376,"column":22}},"136":{"start":{"line":380,"column":26},"end":{"line":380,"column":28}},"137":{"start":{"line":382,"column":8},"end":{"line":397,"column":9}},"138":{"start":{"line":383,"column":22},"end":{"line":383,"column":32}},"139":{"start":{"line":385,"column":12},"end":{"line":388,"column":13}},"140":{"start":{"line":386,"column":16},"end":{"line":386,"column":37}},"141":{"start":{"line":387,"column":16},"end":{"line":387,"column":25}},"142":{"start":{"line":390,"column":25},"end":{"line":390,"column":74}},"143":{"start":{"line":391,"column":12},"end":{"line":391,"column":29}},"144":{"start":{"line":394,"column":12},"end":{"line":396,"column":31}},"145":{"start":{"line":395,"column":16},"end":{"line":396,"column":31}},"146":{"start":{"line":396,"column":20},"end":{"line":396,"column":31}},"147":{"start":{"line":399,"column":8},"end":{"line":399,"column":52}},"148":{"start":{"line":403,"column":8},"end":{"line":408,"column":17}},"149":{"start":{"line":404,"column":12},"end":{"line":408,"column":15}},"150":{"start":{"line":404,"column":58},"end":{"line":408,"column":13}},"151":{"start":{"line":412,"column":8},"end":{"line":418,"column":11}},"152":{"start":{"line":413,"column":12},"end":{"line":417,"column":31}},"153":{"start":{"line":416,"column":20},"end":{"line":416,"column":90}},"154":{"start":{"line":416,"column":40},"end":{"line":416,"column":89}},"155":{"start":{"line":429,"column":8},"end":{"line":429,"column":47}},"156":{"start":{"line":431,"column":19},"end":{"line":434,"column":28}},"157":{"start":{"line":432,"column":12},"end":{"line":434,"column":28}},"158":{"start":{"line":432,"column":19},"end":{"line":434,"column":28}},"159":{"start":{"line":436,"column":8},"end":{"line":436,"column":51}},"160":{"start":{"line":438,"column":8},"end":{"line":438,"column":20}},"161":{"start":{"line":451,"column":8},"end":{"line":451,"column":28}},"162":{"start":{"line":452,"column":8},"end":{"line":452,"column":28}},"163":{"start":{"line":453,"column":8},"end":{"line":453,"column":28}},"164":{"start":{"line":454,"column":8},"end":{"line":454,"column":61}},"165":{"start":{"line":456,"column":8},"end":{"line":460,"column":9}},"166":{"start":{"line":457,"column":12},"end":{"line":457,"column":24}},"167":{"start":{"line":458,"column":12},"end":{"line":458,"column":24}},"168":{"start":{"line":459,"column":12},"end":{"line":459,"column":22}},"169":{"start":{"line":462,"column":8},"end":{"line":478,"column":11}},"170":{"start":{"line":463,"column":12},"end":{"line":464,"column":73}},"171":{"start":{"line":464,"column":16},"end":{"line":464,"column":73}},"172":{"start":{"line":466,"column":12},"end":{"line":477,"column":39}},"173":{"start":{"line":470,"column":16},"end":{"line":477,"column":37}},"174":{"start":{"line":475,"column":29},"end":{"line":477,"column":36}},"175":{"start":{"line":488,"column":0},"end":{"line":490,"column":2}},"176":{"start":{"line":489,"column":4},"end":{"line":489,"column":48}},"177":{"start":{"line":492,"column":0},"end":{"line":492,"column":21}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":30,"column":4},"end":{"line":30,"column":5}},"loc":{"start":{"line":30,"column":21},"end":{"line":41,"column":5}},"line":30},"1":{"name":"(anonymous_1)","decl":{"start":{"line":43,"column":4},"end":{"line":43,"column":5}},"loc":{"start":{"line":43,"column":23},"end":{"line":45,"column":5}},"line":43},"2":{"name":"(anonymous_2)","decl":{"start":{"line":53,"column":4},"end":{"line":53,"column":5}},"loc":{"start":{"line":53,"column":14},"end":{"line":64,"column":5}},"line":53},"3":{"name":"(anonymous_3)","decl":{"start":{"line":56,"column":34},"end":{"line":56,"column":35}},"loc":{"start":{"line":56,"column":46},"end":{"line":58,"column":9}},"line":56},"4":{"name":"(anonymous_4)","decl":{"start":{"line":61,"column":34},"end":{"line":61,"column":35}},"loc":{"start":{"line":61,"column":41},"end":{"line":61,"column":76}},"line":61},"5":{"name":"(anonymous_5)","decl":{"start":{"line":66,"column":4},"end":{"line":66,"column":5}},"loc":{"start":{"line":66,"column":17},"end":{"line":75,"column":5}},"line":66},"6":{"name":"(anonymous_6)","decl":{"start":{"line":77,"column":4},"end":{"line":77,"column":5}},"loc":{"start":{"line":77,"column":20},"end":{"line":79,"column":5}},"line":77},"7":{"name":"(anonymous_7)","decl":{"start":{"line":87,"column":4},"end":{"line":87,"column":5}},"loc":{"start":{"line":87,"column":15},"end":{"line":94,"column":5}},"line":87},"8":{"name":"(anonymous_8)","decl":{"start":{"line":102,"column":4},"end":{"line":102,"column":5}},"loc":{"start":{"line":102,"column":13},"end":{"line":106,"column":5}},"line":102},"9":{"name":"(anonymous_9)","decl":{"start":{"line":113,"column":4},"end":{"line":113,"column":5}},"loc":{"start":{"line":113,"column":10},"end":{"line":115,"column":5}},"line":113},"10":{"name":"(anonymous_10)","decl":{"start":{"line":122,"column":4},"end":{"line":122,"column":5}},"loc":{"start":{"line":122,"column":10},"end":{"line":124,"column":5}},"line":122},"11":{"name":"(anonymous_11)","decl":{"start":{"line":140,"column":4},"end":{"line":140,"column":5}},"loc":{"start":{"line":140,"column":20},"end":{"line":147,"column":5}},"line":140},"12":{"name":"(anonymous_12)","decl":{"start":{"line":154,"column":4},"end":{"line":154,"column":5}},"loc":{"start":{"line":154,"column":14},"end":{"line":166,"column":5}},"line":154},"13":{"name":"(anonymous_13)","decl":{"start":{"line":162,"column":17},"end":{"line":162,"column":18}},"loc":{"start":{"line":162,"column":28},"end":{"line":164,"column":13}},"line":162},"14":{"name":"(anonymous_14)","decl":{"start":{"line":175,"column":4},"end":{"line":175,"column":5}},"loc":{"start":{"line":175,"column":18},"end":{"line":180,"column":5}},"line":175},"15":{"name":"(anonymous_15)","decl":{"start":{"line":188,"column":4},"end":{"line":188,"column":5}},"loc":{"start":{"line":188,"column":24},"end":{"line":191,"column":5}},"line":188},"16":{"name":"(anonymous_16)","decl":{"start":{"line":193,"column":4},"end":{"line":193,"column":5}},"loc":{"start":{"line":193,"column":21},"end":{"line":198,"column":5}},"line":193},"17":{"name":"(anonymous_17)","decl":{"start":{"line":194,"column":36},"end":{"line":194,"column":37}},"loc":{"start":{"line":194,"column":47},"end":{"line":197,"column":9}},"line":194},"18":{"name":"(anonymous_18)","decl":{"start":{"line":205,"column":4},"end":{"line":205,"column":5}},"loc":{"start":{"line":205,"column":12},"end":{"line":231,"column":5}},"line":205},"19":{"name":"(anonymous_19)","decl":{"start":{"line":233,"column":4},"end":{"line":233,"column":5}},"loc":{"start":{"line":233,"column":13},"end":{"line":235,"column":5}},"line":233},"20":{"name":"(anonymous_20)","decl":{"start":{"line":237,"column":4},"end":{"line":237,"column":5}},"loc":{"start":{"line":237,"column":23},"end":{"line":243,"column":5}},"line":237},"21":{"name":"(anonymous_21)","decl":{"start":{"line":241,"column":27},"end":{"line":241,"column":28}},"loc":{"start":{"line":241,"column":32},"end":{"line":241,"column":49}},"line":241},"22":{"name":"(anonymous_22)","decl":{"start":{"line":245,"column":4},"end":{"line":245,"column":5}},"loc":{"start":{"line":245,"column":17},"end":{"line":247,"column":5}},"line":245},"23":{"name":"(anonymous_23)","decl":{"start":{"line":249,"column":4},"end":{"line":249,"column":5}},"loc":{"start":{"line":249,"column":16},"end":{"line":251,"column":5}},"line":249},"24":{"name":"(anonymous_24)","decl":{"start":{"line":253,"column":4},"end":{"line":253,"column":5}},"loc":{"start":{"line":253,"column":25},"end":{"line":260,"column":5}},"line":253},"25":{"name":"(anonymous_25)","decl":{"start":{"line":262,"column":4},"end":{"line":262,"column":5}},"loc":{"start":{"line":262,"column":31},"end":{"line":270,"column":5}},"line":262},"26":{"name":"(anonymous_26)","decl":{"start":{"line":263,"column":27},"end":{"line":263,"column":28}},"loc":{"start":{"line":263,"column":34},"end":{"line":263,"column":77}},"line":263},"27":{"name":"(anonymous_27)","decl":{"start":{"line":272,"column":4},"end":{"line":272,"column":5}},"loc":{"start":{"line":272,"column":30},"end":{"line":326,"column":5}},"line":272},"28":{"name":"(anonymous_28)","decl":{"start":{"line":328,"column":4},"end":{"line":328,"column":5}},"loc":{"start":{"line":328,"column":28},"end":{"line":368,"column":5}},"line":328},"29":{"name":"(anonymous_29)","decl":{"start":{"line":370,"column":4},"end":{"line":370,"column":5}},"loc":{"start":{"line":370,"column":31},"end":{"line":377,"column":5}},"line":370},"30":{"name":"(anonymous_30)","decl":{"start":{"line":379,"column":4},"end":{"line":379,"column":5}},"loc":{"start":{"line":379,"column":33},"end":{"line":400,"column":5}},"line":379},"31":{"name":"(anonymous_31)","decl":{"start":{"line":402,"column":4},"end":{"line":402,"column":5}},"loc":{"start":{"line":402,"column":20},"end":{"line":409,"column":5}},"line":402},"32":{"name":"(anonymous_32)","decl":{"start":{"line":403,"column":44},"end":{"line":403,"column":45}},"loc":{"start":{"line":404,"column":12},"end":{"line":408,"column":15}},"line":404},"33":{"name":"(anonymous_33)","decl":{"start":{"line":404,"column":52},"end":{"line":404,"column":53}},"loc":{"start":{"line":404,"column":58},"end":{"line":408,"column":13}},"line":404},"34":{"name":"(anonymous_34)","decl":{"start":{"line":411,"column":4},"end":{"line":411,"column":5}},"loc":{"start":{"line":411,"column":22},"end":{"line":419,"column":5}},"line":411},"35":{"name":"(anonymous_35)","decl":{"start":{"line":412,"column":36},"end":{"line":412,"column":37}},"loc":{"start":{"line":412,"column":45},"end":{"line":418,"column":9}},"line":412},"36":{"name":"(anonymous_36)","decl":{"start":{"line":415,"column":24},"end":{"line":415,"column":25}},"loc":{"start":{"line":416,"column":20},"end":{"line":416,"column":90}},"line":416},"37":{"name":"(anonymous_37)","decl":{"start":{"line":416,"column":32},"end":{"line":416,"column":33}},"loc":{"start":{"line":416,"column":40},"end":{"line":416,"column":89}},"line":416},"38":{"name":"(anonymous_38)","decl":{"start":{"line":428,"column":4},"end":{"line":428,"column":5}},"loc":{"start":{"line":428,"column":14},"end":{"line":439,"column":5}},"line":428},"39":{"name":"(anonymous_39)","decl":{"start":{"line":431,"column":19},"end":{"line":431,"column":20}},"loc":{"start":{"line":432,"column":12},"end":{"line":434,"column":28}},"line":432},"40":{"name":"(anonymous_40)","decl":{"start":{"line":432,"column":12},"end":{"line":432,"column":13}},"loc":{"start":{"line":432,"column":19},"end":{"line":434,"column":28}},"line":432},"41":{"name":"(anonymous_41)","decl":{"start":{"line":450,"column":4},"end":{"line":450,"column":5}},"loc":{"start":{"line":450,"column":29},"end":{"line":479,"column":5}},"line":450},"42":{"name":"(anonymous_42)","decl":{"start":{"line":462,"column":44},"end":{"line":462,"column":45}},"loc":{"start":{"line":462,"column":49},"end":{"line":478,"column":9}},"line":462},"43":{"name":"(anonymous_43)","decl":{"start":{"line":469,"column":22},"end":{"line":469,"column":23}},"loc":{"start":{"line":470,"column":16},"end":{"line":477,"column":37}},"line":470},"44":{"name":"(anonymous_44)","decl":{"start":{"line":475,"column":22},"end":{"line":475,"column":23}},"loc":{"start":{"line":475,"column":29},"end":{"line":477,"column":36}},"line":475},"45":{"name":"(anonymous_45)","decl":{"start":{"line":488,"column":19},"end":{"line":488,"column":20}},"loc":{"start":{"line":488,"column":34},"end":{"line":490,"column":1}},"line":488}},"branchMap":{"0":{"loc":{"start":{"line":56,"column":8},"end":{"line":58,"column":10}},"type":"binary-expr","locations":[{"start":{"line":56,"column":8},"end":{"line":56,"column":17}},{"start":{"line":56,"column":22},"end":{"line":58,"column":9}}],"line":56},"1":{"loc":{"start":{"line":67,"column":20},"end":{"line":67,"column":31}},"type":"binary-expr","locations":[{"start":{"line":67,"column":20},"end":{"line":67,"column":23}},{"start":{"line":67,"column":27},"end":{"line":67,"column":31}}],"line":67},"2":{"loc":{"start":{"line":69,"column":8},"end":{"line":72,"column":54}},"type":"binary-expr","locations":[{"start":{"line":69,"column":8},"end":{"line":69,"column":22}},{"start":{"line":70,"column":12},"end":{"line":70,"column":32}},{"start":{"line":71,"column":12},"end":{"line":71,"column":22}},{"start":{"line":72,"column":13},"end":{"line":72,"column":53}}],"line":69},"3":{"loc":{"start":{"line":90,"column":8},"end":{"line":91,"column":48}},"type":"binary-expr","locations":[{"start":{"line":90,"column":8},"end":{"line":90,"column":22}},{"start":{"line":91,"column":13},"end":{"line":91,"column":47}}],"line":90},"4":{"loc":{"start":{"line":103,"column":15},"end":{"line":105,"column":27}},"type":"cond-expr","locations":[{"start":{"line":104,"column":12},"end":{"line":104,"column":29}},{"start":{"line":105,"column":14},"end":{"line":105,"column":27}}],"line":103},"5":{"loc":{"start":{"line":141,"column":8},"end":{"line":141,"column":29}},"type":"if","locations":[{"start":{"line":141,"column":8},"end":{"line":141,"column":29}},{"start":{"line":141,"column":8},"end":{"line":141,"column":29}}],"line":141},"6":{"loc":{"start":{"line":143,"column":8},"end":{"line":143,"column":49}},"type":"binary-expr","locations":[{"start":{"line":143,"column":9},"end":{"line":143,"column":19}},{"start":{"line":143,"column":23},"end":{"line":143,"column":28}},{"start":{"line":143,"column":34},"end":{"line":143,"column":48}}],"line":143},"7":{"loc":{"start":{"line":189,"column":20},"end":{"line":189,"column":35}},"type":"binary-expr","locations":[{"start":{"line":189,"column":20},"end":{"line":189,"column":27}},{"start":{"line":189,"column":31},"end":{"line":189,"column":35}}],"line":189},"8":{"loc":{"start":{"line":195,"column":12},"end":{"line":195,"column":61}},"type":"binary-expr","locations":[{"start":{"line":195,"column":12},"end":{"line":195,"column":15}},{"start":{"line":195,"column":19},"end":{"line":195,"column":61}}],"line":195},"9":{"loc":{"start":{"line":195,"column":27},"end":{"line":195,"column":55}},"type":"cond-expr","locations":[{"start":{"line":195,"column":40},"end":{"line":195,"column":45}},{"start":{"line":195,"column":48},"end":{"line":195,"column":55}}],"line":195},"10":{"loc":{"start":{"line":196,"column":25},"end":{"line":196,"column":34}},"type":"binary-expr","locations":[{"start":{"line":196,"column":25},"end":{"line":196,"column":29}},{"start":{"line":196,"column":33},"end":{"line":196,"column":34}}],"line":196},"11":{"loc":{"start":{"line":208,"column":8},"end":{"line":208,"column":50}},"type":"binary-expr","locations":[{"start":{"line":208,"column":8},"end":{"line":208,"column":19}},{"start":{"line":208,"column":23},"end":{"line":208,"column":50}}],"line":208},"12":{"loc":{"start":{"line":212,"column":8},"end":{"line":216,"column":24}},"type":"binary-expr","locations":[{"start":{"line":212,"column":8},"end":{"line":212,"column":25}},{"start":{"line":213,"column":15},"end":{"line":216,"column":24}}],"line":212},"13":{"loc":{"start":{"line":218,"column":8},"end":{"line":222,"column":24}},"type":"binary-expr","locations":[{"start":{"line":218,"column":9},"end":{"line":218,"column":46}},{"start":{"line":219,"column":15},"end":{"line":222,"column":24}}],"line":218},"14":{"loc":{"start":{"line":238,"column":8},"end":{"line":238,"column":30}},"type":"if","locations":[{"start":{"line":238,"column":8},"end":{"line":238,"column":30}},{"start":{"line":238,"column":8},"end":{"line":238,"column":30}}],"line":238},"15":{"loc":{"start":{"line":246,"column":18},"end":{"line":246,"column":67}},"type":"cond-expr","locations":[{"start":{"line":246,"column":34},"end":{"line":246,"column":36}},{"start":{"line":246,"column":39},"end":{"line":246,"column":67}}],"line":246},"16":{"loc":{"start":{"line":250,"column":18},"end":{"line":250,"column":66}},"type":"cond-expr","locations":[{"start":{"line":250,"column":34},"end":{"line":250,"column":36}},{"start":{"line":250,"column":39},"end":{"line":250,"column":66}}],"line":250},"17":{"loc":{"start":{"line":255,"column":8},"end":{"line":255,"column":30}},"type":"if","locations":[{"start":{"line":255,"column":8},"end":{"line":255,"column":30}},{"start":{"line":255,"column":8},"end":{"line":255,"column":30}}],"line":255},"18":{"loc":{"start":{"line":257,"column":15},"end":{"line":259,"column":34}},"type":"cond-expr","locations":[{"start":{"line":258,"column":12},"end":{"line":258,"column":21}},{"start":{"line":259,"column":12},"end":{"line":259,"column":34}}],"line":257},"19":{"loc":{"start":{"line":263,"column":8},"end":{"line":263,"column":87}},"type":"if","locations":[{"start":{"line":263,"column":8},"end":{"line":263,"column":87}},{"start":{"line":263,"column":8},"end":{"line":263,"column":87}}],"line":263},"20":{"loc":{"start":{"line":263,"column":34},"end":{"line":263,"column":77}},"type":"binary-expr","locations":[{"start":{"line":263,"column":34},"end":{"line":263,"column":43}},{"start":{"line":263,"column":47},"end":{"line":263,"column":77}}],"line":263},"21":{"loc":{"start":{"line":268,"column":12},"end":{"line":269,"column":54}},"type":"if","locations":[{"start":{"line":268,"column":12},"end":{"line":269,"column":54}},{"start":{"line":268,"column":12},"end":{"line":269,"column":54}}],"line":268},"22":{"loc":{"start":{"line":268,"column":15},"end":{"line":268,"column":51}},"type":"binary-expr","locations":[{"start":{"line":268,"column":15},"end":{"line":268,"column":21}},{"start":{"line":268,"column":25},"end":{"line":268,"column":51}}],"line":268},"23":{"loc":{"start":{"line":273,"column":8},"end":{"line":273,"column":35}},"type":"binary-expr","locations":[{"start":{"line":273,"column":8},"end":{"line":273,"column":16}},{"start":{"line":273,"column":21},"end":{"line":273,"column":34}}],"line":273},"24":{"loc":{"start":{"line":278,"column":12},"end":{"line":278,"column":46}},"type":"binary-expr","locations":[{"start":{"line":278,"column":12},"end":{"line":278,"column":26}},{"start":{"line":278,"column":31},"end":{"line":278,"column":45}}],"line":278},"25":{"loc":{"start":{"line":280,"column":12},"end":{"line":283,"column":13}},"type":"if","locations":[{"start":{"line":280,"column":12},"end":{"line":283,"column":13}},{"start":{"line":280,"column":12},"end":{"line":283,"column":13}}],"line":280},"26":{"loc":{"start":{"line":280,"column":15},"end":{"line":280,"column":48}},"type":"binary-expr","locations":[{"start":{"line":280,"column":15},"end":{"line":280,"column":22}},{"start":{"line":280,"column":26},"end":{"line":280,"column":48}}],"line":280},"27":{"loc":{"start":{"line":286,"column":12},"end":{"line":318,"column":13}},"type":"if","locations":[{"start":{"line":286,"column":12},"end":{"line":318,"column":13}},{"start":{"line":286,"column":12},"end":{"line":318,"column":13}}],"line":286},"28":{"loc":{"start":{"line":286,"column":15},"end":{"line":286,"column":32}},"type":"binary-expr","locations":[{"start":{"line":286,"column":15},"end":{"line":286,"column":19}},{"start":{"line":286,"column":23},"end":{"line":286,"column":32}}],"line":286},"29":{"loc":{"start":{"line":287,"column":16},"end":{"line":298,"column":38}},"type":"if","locations":[{"start":{"line":287,"column":16},"end":{"line":298,"column":38}},{"start":{"line":287,"column":16},"end":{"line":298,"column":38}}],"line":287},"30":{"loc":{"start":{"line":292,"column":24},"end":{"line":292,"column":46}},"type":"if","locations":[{"start":{"line":292,"column":24},"end":{"line":292,"column":46}},{"start":{"line":292,"column":24},"end":{"line":292,"column":46}}],"line":292},"31":{"loc":{"start":{"line":295,"column":23},"end":{"line":298,"column":38}},"type":"if","locations":[{"start":{"line":295,"column":23},"end":{"line":298,"column":38}},{"start":{"line":295,"column":23},"end":{"line":298,"column":38}}],"line":295},"32":{"loc":{"start":{"line":296,"column":26},"end":{"line":298,"column":37}},"type":"cond-expr","locations":[{"start":{"line":297,"column":24},"end":{"line":297,"column":49}},{"start":{"line":298,"column":24},"end":{"line":298,"column":37}}],"line":296},"33":{"loc":{"start":{"line":307,"column":16},"end":{"line":317,"column":17}},"type":"if","locations":[{"start":{"line":307,"column":16},"end":{"line":317,"column":17}},{"start":{"line":307,"column":16},"end":{"line":317,"column":17}}],"line":307},"34":{"loc":{"start":{"line":308,"column":20},"end":{"line":314,"column":70}},"type":"if","locations":[{"start":{"line":308,"column":20},"end":{"line":314,"column":70}},{"start":{"line":308,"column":20},"end":{"line":314,"column":70}}],"line":308},"35":{"loc":{"start":{"line":310,"column":27},"end":{"line":314,"column":70}},"type":"if","locations":[{"start":{"line":310,"column":27},"end":{"line":314,"column":70}},{"start":{"line":310,"column":27},"end":{"line":314,"column":70}}],"line":310},"36":{"loc":{"start":{"line":320,"column":12},"end":{"line":320,"column":57}},"type":"if","locations":[{"start":{"line":320,"column":12},"end":{"line":320,"column":57}},{"start":{"line":320,"column":12},"end":{"line":320,"column":57}}],"line":320},"37":{"loc":{"start":{"line":336,"column":12},"end":{"line":349,"column":13}},"type":"if","locations":[{"start":{"line":336,"column":12},"end":{"line":349,"column":13}},{"start":{"line":336,"column":12},"end":{"line":349,"column":13}}],"line":336},"38":{"loc":{"start":{"line":336,"column":15},"end":{"line":336,"column":41}},"type":"binary-expr","locations":[{"start":{"line":336,"column":15},"end":{"line":336,"column":25}},{"start":{"line":336,"column":29},"end":{"line":336,"column":41}}],"line":336},"39":{"loc":{"start":{"line":338,"column":16},"end":{"line":341,"column":17}},"type":"if","locations":[{"start":{"line":338,"column":16},"end":{"line":341,"column":17}},{"start":{"line":338,"column":16},"end":{"line":341,"column":17}}],"line":338},"40":{"loc":{"start":{"line":340,"column":20},"end":{"line":340,"column":66}},"type":"binary-expr","locations":[{"start":{"line":340,"column":20},"end":{"line":340,"column":44}},{"start":{"line":340,"column":48},"end":{"line":340,"column":66}}],"line":340},"41":{"loc":{"start":{"line":344,"column":16},"end":{"line":344,"column":68}},"type":"if","locations":[{"start":{"line":344,"column":16},"end":{"line":344,"column":68}},{"start":{"line":344,"column":16},"end":{"line":344,"column":68}}],"line":344},"42":{"loc":{"start":{"line":346,"column":16},"end":{"line":346,"column":74}},"type":"if","locations":[{"start":{"line":346,"column":16},"end":{"line":346,"column":74}},{"start":{"line":346,"column":16},"end":{"line":346,"column":74}}],"line":346},"43":{"loc":{"start":{"line":351,"column":12},"end":{"line":351,"column":46}},"type":"binary-expr","locations":[{"start":{"line":351,"column":12},"end":{"line":351,"column":22}},{"start":{"line":351,"column":27},"end":{"line":351,"column":45}}],"line":351},"44":{"loc":{"start":{"line":352,"column":12},"end":{"line":352,"column":41}},"type":"binary-expr","locations":[{"start":{"line":352,"column":12},"end":{"line":352,"column":28}},{"start":{"line":352,"column":33},"end":{"line":352,"column":40}}],"line":352},"45":{"loc":{"start":{"line":357,"column":16},"end":{"line":357,"column":70}},"type":"if","locations":[{"start":{"line":357,"column":16},"end":{"line":357,"column":70}},{"start":{"line":357,"column":16},"end":{"line":357,"column":70}}],"line":357},"46":{"loc":{"start":{"line":359,"column":16},"end":{"line":359,"column":54}},"type":"binary-expr","locations":[{"start":{"line":359,"column":16},"end":{"line":359,"column":24}},{"start":{"line":359,"column":28},"end":{"line":359,"column":54}}],"line":359},"47":{"loc":{"start":{"line":360,"column":16},"end":{"line":360,"column":71}},"type":"if","locations":[{"start":{"line":360,"column":16},"end":{"line":360,"column":71}},{"start":{"line":360,"column":16},"end":{"line":360,"column":71}}],"line":360},"48":{"loc":{"start":{"line":372,"column":12},"end":{"line":374,"column":48}},"type":"binary-expr","locations":[{"start":{"line":372,"column":12},"end":{"line":372,"column":21}},{"start":{"line":373,"column":16},"end":{"line":373,"column":50}},{"start":{"line":374,"column":16},"end":{"line":374,"column":48}}],"line":372},"49":{"loc":{"start":{"line":385,"column":12},"end":{"line":388,"column":13}},"type":"if","locations":[{"start":{"line":385,"column":12},"end":{"line":388,"column":13}},{"start":{"line":385,"column":12},"end":{"line":388,"column":13}}],"line":385},"50":{"loc":{"start":{"line":390,"column":25},"end":{"line":390,"column":74}},"type":"cond-expr","locations":[{"start":{"line":390,"column":51},"end":{"line":390,"column":60}},{"start":{"line":390,"column":63},"end":{"line":390,"column":74}}],"line":390},"51":{"loc":{"start":{"line":395,"column":16},"end":{"line":396,"column":31}},"type":"if","locations":[{"start":{"line":395,"column":16},"end":{"line":396,"column":31}},{"start":{"line":395,"column":16},"end":{"line":396,"column":31}}],"line":395},"52":{"loc":{"start":{"line":414,"column":24},"end":{"line":414,"column":44}},"type":"binary-expr","locations":[{"start":{"line":414,"column":24},"end":{"line":414,"column":38}},{"start":{"line":414,"column":42},"end":{"line":414,"column":44}}],"line":414},"53":{"loc":{"start":{"line":429,"column":8},"end":{"line":429,"column":46}},"type":"binary-expr","locations":[{"start":{"line":429,"column":8},"end":{"line":429,"column":12}},{"start":{"line":429,"column":17},"end":{"line":429,"column":45}}],"line":429},"54":{"loc":{"start":{"line":432,"column":19},"end":{"line":434,"column":28}},"type":"cond-expr","locations":[{"start":{"line":433,"column":16},"end":{"line":433,"column":115}},{"start":{"line":434,"column":16},"end":{"line":434,"column":28}}],"line":432},"55":{"loc":{"start":{"line":433,"column":27},"end":{"line":433,"column":54}},"type":"binary-expr","locations":[{"start":{"line":433,"column":27},"end":{"line":433,"column":36}},{"start":{"line":433,"column":40},"end":{"line":433,"column":54}}],"line":433},"56":{"loc":{"start":{"line":433,"column":56},"end":{"line":433,"column":114}},"type":"binary-expr","locations":[{"start":{"line":433,"column":57},"end":{"line":433,"column":108}},{"start":{"line":433,"column":113},"end":{"line":433,"column":114}}],"line":433},"57":{"loc":{"start":{"line":433,"column":57},"end":{"line":433,"column":108}},"type":"cond-expr","locations":[{"start":{"line":433,"column":89},"end":{"line":433,"column":101}},{"start":{"line":433,"column":104},"end":{"line":433,"column":108}}],"line":433},"58":{"loc":{"start":{"line":451,"column":8},"end":{"line":451,"column":27}},"type":"binary-expr","locations":[{"start":{"line":451,"column":8},"end":{"line":451,"column":12}},{"start":{"line":451,"column":17},"end":{"line":451,"column":26}}],"line":451},"59":{"loc":{"start":{"line":452,"column":8},"end":{"line":452,"column":27}},"type":"binary-expr","locations":[{"start":{"line":452,"column":8},"end":{"line":452,"column":12}},{"start":{"line":452,"column":17},"end":{"line":452,"column":26}}],"line":452},"60":{"loc":{"start":{"line":453,"column":8},"end":{"line":453,"column":27}},"type":"binary-expr","locations":[{"start":{"line":453,"column":8},"end":{"line":453,"column":12}},{"start":{"line":453,"column":17},"end":{"line":453,"column":26}}],"line":453},"61":{"loc":{"start":{"line":454,"column":8},"end":{"line":454,"column":60}},"type":"binary-expr","locations":[{"start":{"line":454,"column":8},"end":{"line":454,"column":32}},{"start":{"line":454,"column":37},"end":{"line":454,"column":59}}],"line":454},"62":{"loc":{"start":{"line":456,"column":8},"end":{"line":460,"column":9}},"type":"if","locations":[{"start":{"line":456,"column":8},"end":{"line":460,"column":9}},{"start":{"line":456,"column":8},"end":{"line":460,"column":9}}],"line":456},"63":{"loc":{"start":{"line":456,"column":11},"end":{"line":456,"column":55}},"type":"binary-expr","locations":[{"start":{"line":456,"column":11},"end":{"line":456,"column":31}},{"start":{"line":456,"column":35},"end":{"line":456,"column":55}}],"line":456},"64":{"loc":{"start":{"line":463,"column":12},"end":{"line":464,"column":73}},"type":"if","locations":[{"start":{"line":463,"column":12},"end":{"line":464,"column":73}},{"start":{"line":463,"column":12},"end":{"line":464,"column":73}}],"line":463},"65":{"loc":{"start":{"line":475,"column":29},"end":{"line":477,"column":36}},"type":"cond-expr","locations":[{"start":{"line":476,"column":20},"end":{"line":476,"column":34}},{"start":{"line":477,"column":20},"end":{"line":477,"column":36}}],"line":475},"66":{"loc":{"start":{"line":475,"column":30},"end":{"line":475,"column":55}},"type":"binary-expr","locations":[{"start":{"line":475,"column":30},"end":{"line":475,"column":33}},{"start":{"line":475,"column":37},"end":{"line":475,"column":55}}],"line":475},"67":{"loc":{"start":{"line":489,"column":35},"end":{"line":489,"column":45}},"type":"binary-expr","locations":[{"start":{"line":489,"column":35},"end":{"line":489,"column":39}},{"start":{"line":489,"column":43},"end":{"line":489,"column":45}}],"line":489}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":0,"108":0,"109":0,"110":0,"111":0,"112":0,"113":0,"114":0,"115":0,"116":0,"117":0,"118":0,"119":0,"120":0,"121":0,"122":0,"123":0,"124":0,"125":0,"126":0,"127":0,"128":0,"129":0,"130":0,"131":0,"132":0,"133":0,"134":0,"135":0,"136":0,"137":0,"138":0,"139":0,"140":0,"141":0,"142":0,"143":0,"144":0,"145":0,"146":0,"147":0,"148":0,"149":0,"150":0,"151":0,"152":0,"153":0,"154":0,"155":0,"156":0,"157":0,"158":0,"159":0,"160":0,"161":0,"162":0,"163":0,"164":0,"165":0,"166":0,"167":0,"168":0,"169":0,"170":0,"171":0,"172":0,"173":0,"174":0,"175":1,"176":0,"177":1},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0},"b":{"0":[0,0],"1":[0,0],"2":[0,0,0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[0,0],"17":[0,0],"18":[0,0],"19":[0,0],"20":[0,0],"21":[0,0],"22":[0,0],"23":[0,0],"24":[0,0],"25":[0,0],"26":[0,0],"27":[0,0],"28":[0,0],"29":[0,0],"30":[0,0],"31":[0,0],"32":[0,0],"33":[0,0],"34":[0,0],"35":[0,0],"36":[0,0],"37":[0,0],"38":[0,0],"39":[0,0],"40":[0,0],"41":[0,0],"42":[0,0],"43":[0,0],"44":[0,0],"45":[0,0],"46":[0,0],"47":[0,0],"48":[0,0,0],"49":[0,0],"50":[0,0],"51":[0,0],"52":[0,0],"53":[0,0],"54":[0,0],"55":[0,0],"56":[0,0],"57":[0,0],"58":[0,0],"59":[0,0],"60":[0,0],"61":[0,0],"62":[0,0],"63":[0,0],"64":[0,0],"65":[0,0],"66":[0,0],"67":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"dd64a1bfe9159e7f819b97a094ef5960313a71d8","contentHash":"a2af91a1df90f155ec3381cec160f63e_10.3.2"},"/Users/qfox/free/coa/lib/coaobject.js":{"path":"/Users/qfox/free/coa/lib/coaobject.js","statementMap":{"0":{"start":{"line":3,"column":10},"end":{"line":3,"column":22}},"1":{"start":{"line":22,"column":0},"end":{"line":100,"column":2}},"2":{"start":{"line":24,"column":8},"end":{"line":24,"column":24}},"3":{"start":{"line":25,"column":8},"end":{"line":25,"column":26}},"4":{"start":{"line":26,"column":8},"end":{"line":26,"column":27}},"5":{"start":{"line":27,"column":8},"end":{"line":27,"column":26}},"6":{"start":{"line":37,"column":8},"end":{"line":37,"column":26}},"7":{"start":{"line":38,"column":8},"end":{"line":38,"column":20}},"8":{"start":{"line":47,"column":8},"end":{"line":47,"column":28}},"9":{"start":{"line":48,"column":8},"end":{"line":48,"column":20}},"10":{"start":{"line":62,"column":8},"end":{"line":62,"column":26}},"11":{"start":{"line":63,"column":8},"end":{"line":63,"column":20}},"12":{"start":{"line":74,"column":8},"end":{"line":76,"column":28}},"13":{"start":{"line":78,"column":8},"end":{"line":78,"column":20}},"14":{"start":{"line":90,"column":8},"end":{"line":90,"column":32}},"15":{"start":{"line":98,"column":8},"end":{"line":98,"column":25}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":23,"column":4},"end":{"line":23,"column":5}},"loc":{"start":{"line":23,"column":21},"end":{"line":28,"column":5}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":36,"column":4},"end":{"line":36,"column":5}},"loc":{"start":{"line":36,"column":15},"end":{"line":39,"column":5}},"line":36},"2":{"name":"(anonymous_2)","decl":{"start":{"line":46,"column":4},"end":{"line":46,"column":5}},"loc":{"start":{"line":46,"column":17},"end":{"line":49,"column":5}},"line":46},"3":{"name":"(anonymous_3)","decl":{"start":{"line":61,"column":4},"end":{"line":61,"column":5}},"loc":{"start":{"line":61,"column":15},"end":{"line":64,"column":5}},"line":61},"4":{"name":"(anonymous_4)","decl":{"start":{"line":73,"column":4},"end":{"line":73,"column":5}},"loc":{"start":{"line":73,"column":14},"end":{"line":79,"column":5}},"line":73},"5":{"name":"(anonymous_5)","decl":{"start":{"line":89,"column":4},"end":{"line":89,"column":5}},"loc":{"start":{"line":89,"column":19},"end":{"line":91,"column":5}},"line":89},"6":{"name":"(anonymous_6)","decl":{"start":{"line":97,"column":4},"end":{"line":97,"column":5}},"loc":{"start":{"line":97,"column":10},"end":{"line":99,"column":5}},"line":97}},"branchMap":{"0":{"loc":{"start":{"line":74,"column":8},"end":{"line":76,"column":27}},"type":"cond-expr","locations":[{"start":{"line":75,"column":12},"end":{"line":75,"column":55}},{"start":{"line":76,"column":14},"end":{"line":76,"column":27}}],"line":74}},"s":{"0":1,"1":1,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0},"b":{"0":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"f650588aa1289c041239086fd69bdb29bac674e3","contentHash":"6d6c8d49c407899e86f5d48b190299f2_10.3.2"},"/Users/qfox/free/coa/lib/color.js":{"path":"/Users/qfox/free/coa/lib/color.js","statementMap":{"0":{"start":{"line":3,"column":15},"end":{"line":20,"column":1}},"1":{"start":{"line":22,"column":0},"end":{"line":22,"column":62}},"2":{"start":{"line":22,"column":29},"end":{"line":22,"column":61}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":22,"column":17},"end":{"line":22,"column":18}},"loc":{"start":{"line":22,"column":29},"end":{"line":22,"column":61}},"line":22}},"branchMap":{},"s":{"0":1,"1":1,"2":0},"f":{"0":0},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"778ccd3d2c0c403fab6192ce73343f2702ec1385","contentHash":"a74567b30ff639029eb97f53646be3e1_10.3.2"},"/Users/qfox/free/coa/lib/opt.js":{"path":"/Users/qfox/free/coa/lib/opt.js","statementMap":{"0":{"start":{"line":4,"column":8},"end":{"line":4,"column":20}},"1":{"start":{"line":6,"column":15},"end":{"line":6,"column":36}},"2":{"start":{"line":7,"column":12},"end":{"line":7,"column":30}},"3":{"start":{"line":18,"column":0},"end":{"line":155,"column":2}},"4":{"start":{"line":24,"column":8},"end":{"line":24,"column":19}},"5":{"start":{"line":26,"column":8},"end":{"line":26,"column":27}},"6":{"start":{"line":27,"column":8},"end":{"line":27,"column":26}},"7":{"start":{"line":28,"column":8},"end":{"line":28,"column":27}},"8":{"start":{"line":29,"column":8},"end":{"line":29,"column":27}},"9":{"start":{"line":30,"column":8},"end":{"line":30,"column":35}},"10":{"start":{"line":40,"column":8},"end":{"line":40,"column":28}},"11":{"start":{"line":41,"column":8},"end":{"line":41,"column":49}},"12":{"start":{"line":42,"column":8},"end":{"line":42,"column":20}},"13":{"start":{"line":52,"column":8},"end":{"line":52,"column":26}},"14":{"start":{"line":53,"column":8},"end":{"line":53,"column":49}},"15":{"start":{"line":54,"column":8},"end":{"line":54,"column":20}},"16":{"start":{"line":63,"column":8},"end":{"line":63,"column":26}},"17":{"start":{"line":64,"column":8},"end":{"line":64,"column":20}},"18":{"start":{"line":74,"column":8},"end":{"line":74,"column":26}},"19":{"start":{"line":75,"column":8},"end":{"line":75,"column":20}},"20":{"start":{"line":95,"column":20},"end":{"line":95,"column":24}},"21":{"start":{"line":96,"column":8},"end":{"line":106,"column":11}},"22":{"start":{"line":97,"column":12},"end":{"line":97,"column":55}},"23":{"start":{"line":97,"column":48},"end":{"line":97,"column":55}},"24":{"start":{"line":99,"column":24},"end":{"line":99,"column":50}},"25":{"start":{"line":100,"column":12},"end":{"line":100,"column":38}},"26":{"start":{"line":100,"column":27},"end":{"line":100,"column":38}},"27":{"start":{"line":102,"column":12},"end":{"line":105,"column":16}},"28":{"start":{"line":102,"column":38},"end":{"line":105,"column":14}},"29":{"start":{"line":103,"column":33},"end":{"line":103,"column":47}},"30":{"start":{"line":108,"column":8},"end":{"line":108,"column":20}},"31":{"start":{"line":112,"column":8},"end":{"line":112,"column":44}},"32":{"start":{"line":114,"column":21},"end":{"line":114,"column":31}},"33":{"start":{"line":115,"column":8},"end":{"line":117,"column":33}},"34":{"start":{"line":119,"column":8},"end":{"line":119,"column":19}},"35":{"start":{"line":123,"column":8},"end":{"line":123,"column":69}},"36":{"start":{"line":127,"column":8},"end":{"line":127,"column":48}},"37":{"start":{"line":131,"column":20},"end":{"line":131,"column":22}},"38":{"start":{"line":132,"column":22},"end":{"line":132,"column":46}},"39":{"start":{"line":134,"column":8},"end":{"line":138,"column":9}},"40":{"start":{"line":135,"column":12},"end":{"line":135,"column":56}},"41":{"start":{"line":136,"column":12},"end":{"line":136,"column":50}},"42":{"start":{"line":137,"column":12},"end":{"line":137,"column":27}},"43":{"start":{"line":140,"column":8},"end":{"line":143,"column":9}},"44":{"start":{"line":141,"column":12},"end":{"line":141,"column":55}},"45":{"start":{"line":142,"column":12},"end":{"line":142,"column":50}},"46":{"start":{"line":145,"column":8},"end":{"line":145,"column":37}},"47":{"start":{"line":147,"column":8},"end":{"line":147,"column":64}},"48":{"start":{"line":149,"column":8},"end":{"line":149,"column":28}},"49":{"start":{"line":153,"column":8},"end":{"line":153,"column":62}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":23,"column":4},"end":{"line":23,"column":5}},"loc":{"start":{"line":23,"column":21},"end":{"line":31,"column":5}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":39,"column":4},"end":{"line":39,"column":5}},"loc":{"start":{"line":39,"column":17},"end":{"line":43,"column":5}},"line":39},"2":{"name":"(anonymous_2)","decl":{"start":{"line":51,"column":4},"end":{"line":51,"column":5}},"loc":{"start":{"line":51,"column":15},"end":{"line":55,"column":5}},"line":51},"3":{"name":"(anonymous_3)","decl":{"start":{"line":62,"column":4},"end":{"line":62,"column":5}},"loc":{"start":{"line":62,"column":11},"end":{"line":65,"column":5}},"line":62},"4":{"name":"(anonymous_4)","decl":{"start":{"line":73,"column":4},"end":{"line":73,"column":5}},"loc":{"start":{"line":73,"column":11},"end":{"line":76,"column":5}},"line":73},"5":{"name":"(anonymous_5)","decl":{"start":{"line":93,"column":4},"end":{"line":93,"column":5}},"loc":{"start":{"line":93,"column":13},"end":{"line":109,"column":5}},"line":93},"6":{"name":"(anonymous_6)","decl":{"start":{"line":96,"column":22},"end":{"line":96,"column":23}},"loc":{"start":{"line":96,"column":37},"end":{"line":106,"column":9}},"line":96},"7":{"name":"(anonymous_7)","decl":{"start":{"line":102,"column":31},"end":{"line":102,"column":32}},"loc":{"start":{"line":102,"column":38},"end":{"line":105,"column":14}},"line":102},"8":{"name":"(anonymous_8)","decl":{"start":{"line":103,"column":27},"end":{"line":103,"column":28}},"loc":{"start":{"line":103,"column":33},"end":{"line":103,"column":47}},"line":103},"9":{"name":"(anonymous_9)","decl":{"start":{"line":111,"column":4},"end":{"line":111,"column":5}},"loc":{"start":{"line":111,"column":24},"end":{"line":120,"column":5}},"line":111},"10":{"name":"(anonymous_10)","decl":{"start":{"line":122,"column":4},"end":{"line":122,"column":5}},"loc":{"start":{"line":122,"column":23},"end":{"line":124,"column":5}},"line":122},"11":{"name":"(anonymous_11)","decl":{"start":{"line":126,"column":4},"end":{"line":126,"column":5}},"loc":{"start":{"line":126,"column":23},"end":{"line":128,"column":5}},"line":126},"12":{"name":"(anonymous_12)","decl":{"start":{"line":130,"column":4},"end":{"line":130,"column":5}},"loc":{"start":{"line":130,"column":13},"end":{"line":150,"column":5}},"line":130},"13":{"name":"(anonymous_13)","decl":{"start":{"line":152,"column":4},"end":{"line":152,"column":5}},"loc":{"start":{"line":152,"column":20},"end":{"line":154,"column":5}},"line":152}},"branchMap":{"0":{"loc":{"start":{"line":97,"column":12},"end":{"line":97,"column":55}},"type":"if","locations":[{"start":{"line":97,"column":12},"end":{"line":97,"column":55}},{"start":{"line":97,"column":12},"end":{"line":97,"column":55}}],"line":97},"1":{"loc":{"start":{"line":100,"column":12},"end":{"line":100,"column":38}},"type":"if","locations":[{"start":{"line":100,"column":12},"end":{"line":100,"column":38}},{"start":{"line":100,"column":12},"end":{"line":100,"column":38}}],"line":100},"2":{"loc":{"start":{"line":112,"column":8},"end":{"line":112,"column":43}},"type":"binary-expr","locations":[{"start":{"line":112,"column":8},"end":{"line":112,"column":17}},{"start":{"line":112,"column":22},"end":{"line":112,"column":42}}],"line":112},"3":{"loc":{"start":{"line":115,"column":8},"end":{"line":117,"column":32}},"type":"cond-expr","locations":[{"start":{"line":116,"column":14},"end":{"line":116,"column":57}},{"start":{"line":117,"column":15},"end":{"line":117,"column":31}}],"line":115},"4":{"loc":{"start":{"line":116,"column":15},"end":{"line":116,"column":46}},"type":"binary-expr","locations":[{"start":{"line":116,"column":15},"end":{"line":116,"column":25}},{"start":{"line":116,"column":30},"end":{"line":116,"column":45}}],"line":116},"5":{"loc":{"start":{"line":123,"column":35},"end":{"line":123,"column":67}},"type":"cond-expr","locations":[{"start":{"line":123,"column":48},"end":{"line":123,"column":52}},{"start":{"line":123,"column":55},"end":{"line":123,"column":67}}],"line":123},"6":{"loc":{"start":{"line":134,"column":8},"end":{"line":138,"column":9}},"type":"if","locations":[{"start":{"line":134,"column":8},"end":{"line":138,"column":9}},{"start":{"line":134,"column":8},"end":{"line":138,"column":9}}],"line":134},"7":{"loc":{"start":{"line":136,"column":12},"end":{"line":136,"column":49}},"type":"binary-expr","locations":[{"start":{"line":136,"column":12},"end":{"line":136,"column":22}},{"start":{"line":136,"column":26},"end":{"line":136,"column":49}}],"line":136},"8":{"loc":{"start":{"line":140,"column":8},"end":{"line":143,"column":9}},"type":"if","locations":[{"start":{"line":140,"column":8},"end":{"line":143,"column":9}},{"start":{"line":140,"column":8},"end":{"line":143,"column":9}}],"line":140},"9":{"loc":{"start":{"line":142,"column":12},"end":{"line":142,"column":49}},"type":"binary-expr","locations":[{"start":{"line":142,"column":12},"end":{"line":142,"column":22}},{"start":{"line":142,"column":26},"end":{"line":142,"column":49}}],"line":142},"10":{"loc":{"start":{"line":147,"column":8},"end":{"line":147,"column":63}},"type":"binary-expr","locations":[{"start":{"line":147,"column":8},"end":{"line":147,"column":17}},{"start":{"line":147,"column":21},"end":{"line":147,"column":63}}],"line":147}},"s":{"0":1,"1":1,"2":1,"3":1,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0},"b":{"0":[0,0],"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"22f25a13c9bf5a0e37b8850b0cb9b8a8568f91e2","contentHash":"f4a81554d63ecea87886eb1fee5da67d_10.3.2"},"/Users/qfox/free/coa/lib/coaparam.js":{"path":"/Users/qfox/free/coa/lib/coaparam.js","statementMap":{"0":{"start":{"line":3,"column":11},"end":{"line":3,"column":24}},"1":{"start":{"line":5,"column":18},"end":{"line":5,"column":40}},"2":{"start":{"line":25,"column":0},"end":{"line":125,"column":2}},"3":{"start":{"line":27,"column":8},"end":{"line":27,"column":19}},"4":{"start":{"line":29,"column":8},"end":{"line":29,"column":26}},"5":{"start":{"line":30,"column":8},"end":{"line":30,"column":26}},"6":{"start":{"line":31,"column":8},"end":{"line":31,"column":30}},"7":{"start":{"line":32,"column":8},"end":{"line":32,"column":30}},"8":{"start":{"line":42,"column":8},"end":{"line":42,"column":25}},"9":{"start":{"line":43,"column":8},"end":{"line":43,"column":20}},"10":{"start":{"line":52,"column":8},"end":{"line":52,"column":25}},"11":{"start":{"line":53,"column":8},"end":{"line":53,"column":20}},"12":{"start":{"line":67,"column":8},"end":{"line":67,"column":24}},"13":{"start":{"line":68,"column":8},"end":{"line":68,"column":20}},"14":{"start":{"line":79,"column":8},"end":{"line":79,"column":24}},"15":{"start":{"line":80,"column":8},"end":{"line":80,"column":20}},"16":{"start":{"line":90,"column":8},"end":{"line":90,"column":30}},"17":{"start":{"line":91,"column":8},"end":{"line":103,"column":15}},"18":{"start":{"line":94,"column":16},"end":{"line":95,"column":29}},"19":{"start":{"line":95,"column":20},"end":{"line":95,"column":29}},"20":{"start":{"line":97,"column":16},"end":{"line":98,"column":41}},"21":{"start":{"line":98,"column":20},"end":{"line":98,"column":41}},"22":{"start":{"line":100,"column":26},"end":{"line":100,"column":71}},"23":{"start":{"line":101,"column":16},"end":{"line":101,"column":26}},"24":{"start":{"line":102,"column":16},"end":{"line":102,"column":25}},"25":{"start":{"line":113,"column":8},"end":{"line":123,"column":15}},"26":{"start":{"line":116,"column":16},"end":{"line":117,"column":29}},"27":{"start":{"line":117,"column":20},"end":{"line":117,"column":29}},"28":{"start":{"line":119,"column":16},"end":{"line":120,"column":42}},"29":{"start":{"line":120,"column":20},"end":{"line":120,"column":42}},"30":{"start":{"line":122,"column":16},"end":{"line":122,"column":70}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":26,"column":4},"end":{"line":26,"column":5}},"loc":{"start":{"line":26,"column":21},"end":{"line":33,"column":5}},"line":26},"1":{"name":"(anonymous_1)","decl":{"start":{"line":41,"column":4},"end":{"line":41,"column":5}},"loc":{"start":{"line":41,"column":10},"end":{"line":44,"column":5}},"line":41},"2":{"name":"(anonymous_2)","decl":{"start":{"line":51,"column":4},"end":{"line":51,"column":5}},"loc":{"start":{"line":51,"column":10},"end":{"line":54,"column":5}},"line":51},"3":{"name":"(anonymous_3)","decl":{"start":{"line":66,"column":4},"end":{"line":66,"column":5}},"loc":{"start":{"line":66,"column":13},"end":{"line":69,"column":5}},"line":66},"4":{"name":"(anonymous_4)","decl":{"start":{"line":78,"column":4},"end":{"line":78,"column":5}},"loc":{"start":{"line":78,"column":13},"end":{"line":81,"column":5}},"line":78},"5":{"name":"(anonymous_5)","decl":{"start":{"line":89,"column":4},"end":{"line":89,"column":5}},"loc":{"start":{"line":89,"column":12},"end":{"line":104,"column":5}},"line":89},"6":{"name":"(anonymous_6)","decl":{"start":{"line":93,"column":17},"end":{"line":93,"column":18}},"loc":{"start":{"line":93,"column":29},"end":{"line":103,"column":13}},"line":93},"7":{"name":"(anonymous_7)","decl":{"start":{"line":112,"column":4},"end":{"line":112,"column":5}},"loc":{"start":{"line":112,"column":13},"end":{"line":124,"column":5}},"line":112},"8":{"name":"(anonymous_8)","decl":{"start":{"line":115,"column":17},"end":{"line":115,"column":18}},"loc":{"start":{"line":115,"column":29},"end":{"line":123,"column":13}},"line":115}},"branchMap":{"0":{"loc":{"start":{"line":94,"column":16},"end":{"line":95,"column":29}},"type":"if","locations":[{"start":{"line":94,"column":16},"end":{"line":95,"column":29}},{"start":{"line":94,"column":16},"end":{"line":95,"column":29}}],"line":94},"1":{"loc":{"start":{"line":97,"column":16},"end":{"line":98,"column":41}},"type":"if","locations":[{"start":{"line":97,"column":16},"end":{"line":98,"column":41}},{"start":{"line":97,"column":16},"end":{"line":98,"column":41}}],"line":97},"2":{"loc":{"start":{"line":116,"column":16},"end":{"line":117,"column":29}},"type":"if","locations":[{"start":{"line":116,"column":16},"end":{"line":117,"column":29}},{"start":{"line":116,"column":16},"end":{"line":117,"column":29}}],"line":116},"3":{"loc":{"start":{"line":119,"column":16},"end":{"line":120,"column":42}},"type":"if","locations":[{"start":{"line":119,"column":16},"end":{"line":120,"column":42}},{"start":{"line":119,"column":16},"end":{"line":120,"column":42}}],"line":119}},"s":{"0":1,"1":1,"2":1,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0},"b":{"0":[0,0],"1":[0,0],"2":[0,0],"3":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"c6478996b826345564ff295d2b66b724b9f061f3","contentHash":"bd97c627f9c8796e49a6ab6004b2a27f_10.3.2"},"/Users/qfox/free/coa/lib/arg.js":{"path":"/Users/qfox/free/coa/lib/arg.js","statementMap":{"0":{"start":{"line":4,"column":15},"end":{"line":4,"column":36}},"1":{"start":{"line":5,"column":12},"end":{"line":5,"column":30}},"2":{"start":{"line":15,"column":0},"end":{"line":58,"column":2}},"3":{"start":{"line":21,"column":8},"end":{"line":21,"column":19}},"4":{"start":{"line":23,"column":8},"end":{"line":23,"column":35}},"5":{"start":{"line":27,"column":8},"end":{"line":27,"column":44}},"6":{"start":{"line":29,"column":21},"end":{"line":29,"column":31}},"7":{"start":{"line":30,"column":8},"end":{"line":32,"column":33}},"8":{"start":{"line":34,"column":8},"end":{"line":34,"column":19}},"9":{"start":{"line":38,"column":8},"end":{"line":38,"column":40}},"10":{"start":{"line":42,"column":8},"end":{"line":42,"column":48}},"11":{"start":{"line":46,"column":20},"end":{"line":46,"column":22}},"12":{"start":{"line":48,"column":8},"end":{"line":48,"column":81}},"13":{"start":{"line":50,"column":8},"end":{"line":50,"column":64}},"14":{"start":{"line":52,"column":8},"end":{"line":52,"column":28}},"15":{"start":{"line":56,"column":8},"end":{"line":56,"column":64}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":20,"column":4},"end":{"line":20,"column":5}},"loc":{"start":{"line":20,"column":21},"end":{"line":24,"column":5}},"line":20},"1":{"name":"(anonymous_1)","decl":{"start":{"line":26,"column":4},"end":{"line":26,"column":5}},"loc":{"start":{"line":26,"column":24},"end":{"line":35,"column":5}},"line":26},"2":{"name":"(anonymous_2)","decl":{"start":{"line":37,"column":4},"end":{"line":37,"column":5}},"loc":{"start":{"line":37,"column":22},"end":{"line":39,"column":5}},"line":37},"3":{"name":"(anonymous_3)","decl":{"start":{"line":41,"column":4},"end":{"line":41,"column":5}},"loc":{"start":{"line":41,"column":29},"end":{"line":43,"column":5}},"line":41},"4":{"name":"(anonymous_4)","decl":{"start":{"line":45,"column":4},"end":{"line":45,"column":5}},"loc":{"start":{"line":45,"column":13},"end":{"line":53,"column":5}},"line":45},"5":{"name":"(anonymous_5)","decl":{"start":{"line":55,"column":4},"end":{"line":55,"column":5}},"loc":{"start":{"line":55,"column":20},"end":{"line":57,"column":5}},"line":55}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":8},"end":{"line":27,"column":43}},"type":"binary-expr","locations":[{"start":{"line":27,"column":8},"end":{"line":27,"column":17}},{"start":{"line":27,"column":22},"end":{"line":27,"column":42}}],"line":27},"1":{"loc":{"start":{"line":30,"column":8},"end":{"line":32,"column":32}},"type":"cond-expr","locations":[{"start":{"line":31,"column":14},"end":{"line":31,"column":57}},{"start":{"line":32,"column":15},"end":{"line":32,"column":31}}],"line":30},"2":{"loc":{"start":{"line":31,"column":15},"end":{"line":31,"column":46}},"type":"binary-expr","locations":[{"start":{"line":31,"column":15},"end":{"line":31,"column":25}},{"start":{"line":31,"column":30},"end":{"line":31,"column":45}}],"line":31},"3":{"loc":{"start":{"line":50,"column":8},"end":{"line":50,"column":63}},"type":"binary-expr","locations":[{"start":{"line":50,"column":8},"end":{"line":50,"column":17}},{"start":{"line":50,"column":21},"end":{"line":50,"column":63}}],"line":50}},"s":{"0":1,"1":1,"2":1,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0},"b":{"0":[0,0],"1":[0,0],"2":[0,0],"3":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"8cccafd5b1e4985b21cc2577017c3df5ffdead02","contentHash":"d21ed1369eebf91835b4c7bc8b7ce3b5_10.3.2"},"/Users/qfox/free/coa/lib/completion.js":{"path":"/Users/qfox/free/coa/lib/completion.js","statementMap":{"0":{"start":{"line":3,"column":18},"end":{"line":3,"column":38}},"1":{"start":{"line":4,"column":11},"end":{"line":4,"column":24}},"2":{"start":{"line":5,"column":13},"end":{"line":5,"column":28}},"3":{"start":{"line":7,"column":10},"end":{"line":7,"column":22}},"4":{"start":{"line":9,"column":14},"end":{"line":9,"column":32}},"5":{"start":{"line":10,"column":15},"end":{"line":10,"column":27}},"6":{"start":{"line":11,"column":17},"end":{"line":11,"column":31}},"7":{"start":{"line":19,"column":0},"end":{"line":58,"column":2}},"8":{"start":{"line":20,"column":4},"end":{"line":57,"column":11}},"9":{"start":{"line":29,"column":12},"end":{"line":34,"column":13}},"10":{"start":{"line":30,"column":26},"end":{"line":30,"column":80}},"11":{"start":{"line":31,"column":16},"end":{"line":31,"column":35}},"12":{"start":{"line":32,"column":16},"end":{"line":32,"column":44}},"13":{"start":{"line":33,"column":16},"end":{"line":33,"column":38}},"14":{"start":{"line":37,"column":12},"end":{"line":41,"column":13}},"15":{"start":{"line":40,"column":16},"end":{"line":40,"column":51}},"16":{"start":{"line":43,"column":12},"end":{"line":43,"column":67}},"17":{"start":{"line":44,"column":12},"end":{"line":44,"column":68}},"18":{"start":{"line":45,"column":12},"end":{"line":45,"column":68}},"19":{"start":{"line":46,"column":12},"end":{"line":46,"column":48}},"20":{"start":{"line":49,"column":12},"end":{"line":49,"column":37}},"21":{"start":{"line":52,"column":27},"end":{"line":52,"column":65}},"22":{"start":{"line":53,"column":12},"end":{"line":56,"column":15}},"23":{"start":{"line":54,"column":16},"end":{"line":54,"column":54}},"24":{"start":{"line":55,"column":16},"end":{"line":55,"column":66}},"25":{"start":{"line":61,"column":18},"end":{"line":61,"column":27}},"26":{"start":{"line":63,"column":4},"end":{"line":69,"column":7}},"27":{"start":{"line":64,"column":8},"end":{"line":64,"column":41}},"28":{"start":{"line":64,"column":16},"end":{"line":64,"column":41}},"29":{"start":{"line":65,"column":8},"end":{"line":65,"column":81}},"30":{"start":{"line":67,"column":8},"end":{"line":67,"column":44}},"31":{"start":{"line":68,"column":8},"end":{"line":68,"column":55}},"32":{"start":{"line":68,"column":38},"end":{"line":68,"column":53}},"33":{"start":{"line":71,"column":4},"end":{"line":71,"column":25}},"34":{"start":{"line":84,"column":8},"end":{"line":84,"column":67}},"35":{"start":{"line":84,"column":42},"end":{"line":84,"column":67}},"36":{"start":{"line":85,"column":8},"end":{"line":85,"column":56}},"37":{"start":{"line":86,"column":8},"end":{"line":86,"column":31}},"38":{"start":{"line":93,"column":17},"end":{"line":93,"column":38}},"39":{"start":{"line":94,"column":14},"end":{"line":94,"column":37}},"40":{"start":{"line":95,"column":18},"end":{"line":95,"column":41}},"41":{"start":{"line":96,"column":18},"end":{"line":96,"column":36}},"42":{"start":{"line":97,"column":17},"end":{"line":97,"column":25}},"43":{"start":{"line":98,"column":24},"end":{"line":98,"column":45}},"44":{"start":{"line":99,"column":25},"end":{"line":99,"column":42}},"45":{"start":{"line":102,"column":22},"end":{"line":102,"column":35}},"46":{"start":{"line":103,"column":12},"end":{"line":103,"column":30}},"47":{"start":{"line":104,"column":4},"end":{"line":104,"column":80}},"48":{"start":{"line":104,"column":76},"end":{"line":104,"column":80}},"49":{"start":{"line":106,"column":4},"end":{"line":106,"column":53}},"50":{"start":{"line":107,"column":4},"end":{"line":107,"column":50}},"51":{"start":{"line":109,"column":4},"end":{"line":118,"column":6}},"52":{"start":{"line":123,"column":17},"end":{"line":123,"column":19}},"53":{"start":{"line":126,"column":4},"end":{"line":148,"column":5}},"54":{"start":{"line":127,"column":8},"end":{"line":127,"column":46}},"55":{"start":{"line":137,"column":18},"end":{"line":137,"column":64}},"56":{"start":{"line":138,"column":8},"end":{"line":147,"column":49}},"57":{"start":{"line":139,"column":12},"end":{"line":139,"column":27}},"58":{"start":{"line":140,"column":12},"end":{"line":140,"column":38}},"59":{"start":{"line":147,"column":12},"end":{"line":147,"column":49}},"60":{"start":{"line":151,"column":4},"end":{"line":151,"column":92}},"61":{"start":{"line":155,"column":4},"end":{"line":161,"column":73}},"62":{"start":{"line":161,"column":26},"end":{"line":161,"column":69}},"63":{"start":{"line":161,"column":46},"end":{"line":161,"column":67}},"64":{"start":{"line":166,"column":4},"end":{"line":166,"column":91}},"65":{"start":{"line":166,"column":77},"end":{"line":166,"column":88}},"66":{"start":{"line":171,"column":4},"end":{"line":175,"column":7}},"67":{"start":{"line":172,"column":8},"end":{"line":172,"column":59}},"68":{"start":{"line":173,"column":8},"end":{"line":173,"column":49}},"69":{"start":{"line":174,"column":8},"end":{"line":174,"column":69}},"70":{"start":{"line":174,"column":34},"end":{"line":174,"column":67}}},"fnMap":{"0":{"name":"completion","decl":{"start":{"line":19,"column":26},"end":{"line":19,"column":36}},"loc":{"start":{"line":19,"column":39},"end":{"line":58,"column":1}},"line":19},"1":{"name":"(anonymous_1)","decl":{"start":{"line":28,"column":13},"end":{"line":28,"column":14}},"loc":{"start":{"line":28,"column":29},"end":{"line":57,"column":9}},"line":28},"2":{"name":"(anonymous_2)","decl":{"start":{"line":53,"column":61},"end":{"line":53,"column":62}},"loc":{"start":{"line":53,"column":71},"end":{"line":56,"column":13}},"line":53},"3":{"name":"dumpScript","decl":{"start":{"line":60,"column":9},"end":{"line":60,"column":19}},"loc":{"start":{"line":60,"column":26},"end":{"line":88,"column":1}},"line":60},"4":{"name":"(anonymous_4)","decl":{"start":{"line":63,"column":66},"end":{"line":63,"column":67}},"loc":{"start":{"line":63,"column":83},"end":{"line":69,"column":5}},"line":63},"5":{"name":"(anonymous_5)","decl":{"start":{"line":68,"column":32},"end":{"line":68,"column":33}},"loc":{"start":{"line":68,"column":38},"end":{"line":68,"column":53}},"line":68},"6":{"name":"onError","decl":{"start":{"line":73,"column":13},"end":{"line":73,"column":20}},"loc":{"start":{"line":73,"column":26},"end":{"line":87,"column":5}},"line":73},"7":{"name":"getOpts","decl":{"start":{"line":90,"column":9},"end":{"line":90,"column":16}},"loc":{"start":{"line":90,"column":23},"end":{"line":119,"column":1}},"line":90},"8":{"name":"complete","decl":{"start":{"line":121,"column":9},"end":{"line":121,"column":17}},"loc":{"start":{"line":121,"column":29},"end":{"line":176,"column":1}},"line":121},"9":{"name":"(anonymous_9)","decl":{"start":{"line":161,"column":16},"end":{"line":161,"column":17}},"loc":{"start":{"line":161,"column":26},"end":{"line":161,"column":69}},"line":161},"10":{"name":"(anonymous_10)","decl":{"start":{"line":161,"column":41},"end":{"line":161,"column":42}},"loc":{"start":{"line":161,"column":46},"end":{"line":161,"column":67}},"line":161},"11":{"name":"(anonymous_11)","decl":{"start":{"line":166,"column":67},"end":{"line":166,"column":68}},"loc":{"start":{"line":166,"column":77},"end":{"line":166,"column":88}},"line":166},"12":{"name":"(anonymous_12)","decl":{"start":{"line":171,"column":26},"end":{"line":171,"column":27}},"loc":{"start":{"line":171,"column":41},"end":{"line":175,"column":5}},"line":171},"13":{"name":"(anonymous_13)","decl":{"start":{"line":174,"column":29},"end":{"line":174,"column":30}},"loc":{"start":{"line":174,"column":34},"end":{"line":174,"column":67}},"line":174}},"branchMap":{"0":{"loc":{"start":{"line":29,"column":12},"end":{"line":34,"column":13}},"type":"if","locations":[{"start":{"line":29,"column":12},"end":{"line":34,"column":13}},{"start":{"line":29,"column":12},"end":{"line":34,"column":13}}],"line":29},"1":{"loc":{"start":{"line":37,"column":12},"end":{"line":41,"column":13}},"type":"if","locations":[{"start":{"line":37,"column":12},"end":{"line":41,"column":13}},{"start":{"line":37,"column":12},"end":{"line":41,"column":13}}],"line":37},"2":{"loc":{"start":{"line":37,"column":15},"end":{"line":39,"column":51}},"type":"binary-expr","locations":[{"start":{"line":37,"column":16},"end":{"line":37,"column":46}},{"start":{"line":38,"column":20},"end":{"line":38,"column":49}},{"start":{"line":39,"column":20},"end":{"line":39,"column":50}}],"line":37},"3":{"loc":{"start":{"line":64,"column":8},"end":{"line":64,"column":41}},"type":"if","locations":[{"start":{"line":64,"column":8},"end":{"line":64,"column":41}},{"start":{"line":64,"column":8},"end":{"line":64,"column":41}}],"line":64},"4":{"loc":{"start":{"line":84,"column":8},"end":{"line":84,"column":67}},"type":"if","locations":[{"start":{"line":84,"column":8},"end":{"line":84,"column":67}},{"start":{"line":84,"column":8},"end":{"line":84,"column":67}}],"line":84},"5":{"loc":{"start":{"line":102,"column":22},"end":{"line":102,"column":35}},"type":"binary-expr","locations":[{"start":{"line":102,"column":22},"end":{"line":102,"column":29}},{"start":{"line":102,"column":33},"end":{"line":102,"column":35}}],"line":102},"6":{"loc":{"start":{"line":104,"column":10},"end":{"line":104,"column":74}},"type":"binary-expr","locations":[{"start":{"line":104,"column":10},"end":{"line":104,"column":65}},{"start":{"line":104,"column":69},"end":{"line":104,"column":74}}],"line":104},"7":{"loc":{"start":{"line":107,"column":4},"end":{"line":107,"column":49}},"type":"binary-expr","locations":[{"start":{"line":107,"column":4},"end":{"line":107,"column":15}},{"start":{"line":107,"column":19},"end":{"line":107,"column":49}}],"line":107},"8":{"loc":{"start":{"line":126,"column":4},"end":{"line":148,"column":5}},"type":"if","locations":[{"start":{"line":126,"column":4},"end":{"line":148,"column":5}},{"start":{"line":126,"column":4},"end":{"line":148,"column":5}}],"line":126},"9":{"loc":{"start":{"line":138,"column":8},"end":{"line":147,"column":49}},"type":"if","locations":[{"start":{"line":138,"column":8},"end":{"line":147,"column":49}},{"start":{"line":138,"column":8},"end":{"line":147,"column":49}}],"line":138},"10":{"loc":{"start":{"line":151,"column":4},"end":{"line":151,"column":91}},"type":"binary-expr","locations":[{"start":{"line":151,"column":4},"end":{"line":151,"column":46}},{"start":{"line":151,"column":51},"end":{"line":151,"column":90}}],"line":151},"11":{"loc":{"start":{"line":155,"column":4},"end":{"line":161,"column":72}},"type":"binary-expr","locations":[{"start":{"line":155,"column":4},"end":{"line":155,"column":11}},{"start":{"line":156,"column":12},"end":{"line":156,"column":41}},{"start":{"line":157,"column":11},"end":{"line":157,"column":21}},{"start":{"line":158,"column":11},"end":{"line":158,"column":20}},{"start":{"line":159,"column":12},"end":{"line":161,"column":71}}],"line":155},"12":{"loc":{"start":{"line":161,"column":47},"end":{"line":161,"column":62}},"type":"binary-expr","locations":[{"start":{"line":161,"column":47},"end":{"line":161,"column":56}},{"start":{"line":161,"column":60},"end":{"line":161,"column":62}}],"line":161},"13":{"loc":{"start":{"line":166,"column":4},"end":{"line":166,"column":90}},"type":"binary-expr","locations":[{"start":{"line":166,"column":4},"end":{"line":166,"column":13}},{"start":{"line":166,"column":18},"end":{"line":166,"column":89}}],"line":166}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0},"b":{"0":[0,0],"1":[0,0],"2":[0,0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0,0,0,0],"12":[0,0],"13":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"bf1c04d4c5a85c2f16524f29049ac84cd5e6c417","contentHash":"98ab868bf205e71228bae99912f21c7d_10.3.2"},"/Users/qfox/free/coa/lib/shell.js":{"path":"/Users/qfox/free/coa/lib/shell.js","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},"1":{"start":{"line":4,"column":4},"end":{"line":6,"column":33}},"2":{"start":{"line":8,"column":4},"end":{"line":8,"column":47}},"3":{"start":{"line":12,"column":4},"end":{"line":12,"column":40}},"4":{"start":{"line":13,"column":4},"end":{"line":13,"column":41}}},"fnMap":{"0":{"name":"unescape","decl":{"start":{"line":3,"column":9},"end":{"line":3,"column":17}},"loc":{"start":{"line":3,"column":21},"end":{"line":9,"column":1}},"line":3},"1":{"name":"escape","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":15}},"loc":{"start":{"line":11,"column":19},"end":{"line":14,"column":1}},"line":11}},"branchMap":{"0":{"loc":{"start":{"line":4,"column":8},"end":{"line":6,"column":32}},"type":"cond-expr","locations":[{"start":{"line":5,"column":10},"end":{"line":5,"column":42}},{"start":{"line":6,"column":10},"end":{"line":6,"column":32}}],"line":4},"1":{"loc":{"start":{"line":13,"column":11},"end":{"line":13,"column":40}},"type":"cond-expr","locations":[{"start":{"line":13,"column":28},"end":{"line":13,"column":36}},{"start":{"line":13,"column":39},"end":{"line":13,"column":40}}],"line":13}},"s":{"0":1,"1":0,"2":0,"3":0,"4":0},"f":{"0":0,"1":0},"b":{"0":[0,0],"1":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"55cde9af51e94a8bfdba0d1e0234ebaa897d4e45","contentHash":"115f610e8268b9114356cd07b4a6f618_10.3.2"}} \ No newline at end of file diff --git a/node_modules/coa/.travis.yml b/node_modules/coa/.travis.yml new file mode 100644 index 00000000..51b4fe68 --- /dev/null +++ b/node_modules/coa/.travis.yml @@ -0,0 +1,9 @@ +language: node_js + +node_js: + - "0.10" + - "0.11" + +matrix: + allow_failures: + - node_js: 0.11 diff --git a/node_modules/coa/GNUmakefile b/node_modules/coa/GNUmakefile new file mode 100644 index 00000000..51db7b68 --- /dev/null +++ b/node_modules/coa/GNUmakefile @@ -0,0 +1,34 @@ +BIN = ./node_modules/.bin + +.PHONY: all +all: lib + +lib: $(foreach s,$(wildcard src/*.coffee),$(patsubst src/%.coffee,lib/%.js,$s)) + +lib-cov: clean-coverage lib + $(BIN)/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib + +lib/%.js: src/%.coffee + $(BIN)/coffee -cb -o $(@D) $< + +.PHONY: test +test: lib + $(BIN)/mocha + +.PHONY: coverage +coverage: lib-cov + COVER=1 $(BIN)/mocha --reporter mocha-istanbul + @echo + @echo Open html-report/index.html file in your browser + +.PHONY: watch +watch: + $(BIN)/coffee --watch --bare --output lib src/*.coffee + +.PHONY: clean +clean: clean-coverage + +.PHONY: clean-coverage +clean-coverage: + -rm -rf lib-cov + -rm -rf html-report diff --git a/node_modules/coa/README.md b/node_modules/coa/README.md new file mode 100644 index 00000000..fc1b0a9f --- /dev/null +++ b/node_modules/coa/README.md @@ -0,0 +1,322 @@ +# Command-Option-Argument +[![build status](https://secure.travis-ci.org/veged/coa.png)](http://travis-ci.org/veged/coa) + +## What is it? + +COA is a parser for command line options that aim to get maximum profit from formalization your program API. +Once you write definition in terms of commands, options and arguments you automaticaly get: + +* Command line help text +* Program API for use COA-based programs as modules +* Shell completion + +### Other features + +* Rich types for options and arguments, such as arrays, boolean flags and required +* Commands can be async throught using promising (powered by [Q](https://github.com/kriskowal/q)) +* Easy submoduling some existing commands to new top-level one +* Combined validation and complex parsing of values + +### TODO + +* Localization +* Shell-mode +* Configs + * Aliases + * Defaults + +## Examples + +````javascript +require('coa').Cmd() // main (top level) command declaration + .name(process.argv[1]) // set top level command name from program name + .title('My awesome command line util') // title for use in text messages + .helpful() // make command "helpful", i.e. options -h --help with usage message + .opt() // add some option + .name('version') // name for use in API + .title('Version') // title for use in text messages + .short('v') // short key: -v + .long('version') // long key: --version + .flag() // for options without value + .act(function(opts) { // add action for option + // return message as result of action + return JSON.parse(require('fs').readFileSync(__dirname + '/package.json')) + .version; + }) + .end() // end option chain and return to main command + .cmd().name('subcommand').apply(require('./subcommand').COA).end() // load subcommand from module + .cmd() // inplace subcommand declaration + .name('othercommand').title('Awesome other subcommand').helpful() + .opt() + .name('input').title('input file, required') + .short('i').long('input') + .val(function(v) { // validator function, also for translate simple values + return require('fs').createReadStream(v) }) + .req() // make option required + .end() // end option chain and return to command + .end() // end subcommand chain and return to parent command + .run(process.argv.slice(2)); // parse and run on process.argv +```` + +````javascript +// subcommand.js +exports.COA = function() { + this + .title('Awesome subcommand').helpful() + .opt() + .name('output').title('output file') + .short('o').long('output') + .output() // use default preset for "output" option declaration + .end() +}; +```` + +## API reference + +### Cmd +Command is a top level entity. Commands may have options and arguments. + +#### Cmd.api +Returns object containing all its subcommands as methods to use from other programs.
+**@returns** *{Object}* + +#### Cmd.name +Set a canonical command identifier to be used anywhere in the API.
+**@param** *String* `_name` command name
+**@returns** *COA.Cmd* `this` instance (for chainability) + +#### Cmd.title +Set a long description for command to be used anywhere in text messages.
+**@param** *String* `_title` command title
+**@returns** *COA.Cmd* `this` instance (for chainability) + +#### Cmd.cmd +Create new or add existing subcommand for current command.
+**@param** *COA.Cmd* `[cmd]` existing command instance
+**@returns** *COA.Cmd* new or added subcommand instance + +#### Cmd.opt +Create option for current command.
+**@returns** *COA.Opt* `new` option instance + +#### Cmd.arg +Create argument for current command.
+**@returns** *COA.Opt* `new` argument instance + +#### Cmd.act +Add (or set) action for current command.
+**@param** *Function* `act` action function, + invoked in the context of command instance + and has the parameters:
+ - *Object* `opts` parsed options
+ - *Array* `args` parsed arguments
+ - *Object* `res` actions result accumulator
+ It can return rejected promise by Cmd.reject (in case of error) + or any other value treated as result.
+**@param** *{Boolean}* [force=false] flag for set action instead add to existings
+**@returns** *COA.Cmd* `this` instance (for chainability) + +#### Cmd.apply +Apply function with arguments in context of command instance.
+**@param** *Function* `fn`
+**@param** *Array* `args`
+**@returns** *COA.Cmd* `this` instance (for chainability) + +#### Cmd.comp +Set custom additional completion for current command.
+**@param** *Function* `fn` completion generation function, + invoked in the context of command instance. + Accepts parameters:
+ - *Object* `opts` completion options
+ It can return promise or any other value treated as result.
+**@returns** *COA.Cmd* `this` instance (for chainability) + +#### Cmd.helpful +Make command "helpful", i.e. add -h --help flags for print usage.
+**@returns** *COA.Cmd* `this` instance (for chainability) + +#### Cmd.completable +Adds shell completion to command, adds "completion" subcommand, that makes all the magic.
+Must be called only on root command.
+**@returns** *COA.Cmd* `this` instance (for chainability) + +#### Cmd.usage +Build full usage text for current command instance.
+**@returns** *String* `usage` text + +#### Cmd.run +Parse arguments from simple format like NodeJS process.argv +and run ahead current program, i.e. call process.exit when all actions done.
+**@param** *Array* `argv`
+**@returns** *COA.Cmd* `this` instance (for chainability) + +#### Cmd.invoke +Invoke specified (or current) command using provided options and arguments.
+**@param** *String|Array* `cmds` subcommand to invoke (optional)
+**@param** *Object* `opts` command options (optional)
+**@param** *Object* `args` command arguments (optional)
+**@returns** *Q.Promise* + +#### Cmd.reject +Return reject of actions results promise.
+Use in .act() for return with error.
+**@param** *Object* `reason` reject reason
+ You can customize toString() method and exitCode property + of reason object.
+**@returns** *Q.promise* rejected promise + +#### Cmd.end +Finish chain for current subcommand and return parent command instance.
+**@returns** *COA.Cmd* `parent` command + +### Opt +Option is a named entity. Options may have short and long keys for use from command line.
+**@namespace**
+**@class** Presents option + +#### Opt.name +Set a canonical option identifier to be used anywhere in the API.
+**@param** *String* `_name` option name
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.title +Set a long description for option to be used anywhere in text messages.
+**@param** *String* `_title` option title
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.short +Set a short key for option to be used with one hyphen from command line.
+**@param** *String* `_short`
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.long +Set a short key for option to be used with double hyphens from command line.
+**@param** *String* `_long`
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.flag +Make an option boolean, i.e. option without value.
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.arr +Makes an option accepts multiple values.
+Otherwise, the value will be used by the latter passed.
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.req +Makes an option req.
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.only +Makes an option to act as a command, +i.e. program will exit just after option action.
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.val +Set a validation (or value) function for argument.
+Value from command line passes through before becoming available from API.
+Using for validation and convertion simple types to any values.
+**@param** *Function* `_val` validating function, + invoked in the context of option instance + and has one parameter with value from command line
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.def +Set a default value for option. +Default value passed through validation function as ordinary value.
+**@param** *Object* `_def`
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.input +Make option value inputting stream. +It's add useful validation and shortcut for STDIN. +**@returns** *{COA.Opt}* `this` instance (for chainability) + +#### Opt.output +Make option value outputing stream.
+It's add useful validation and shortcut for STDOUT.
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.act +Add action for current option command. +This action is performed if the current option +is present in parsed options (with any value).
+**@param** *Function* `act` action function, + invoked in the context of command instance + and has the parameters:
+ - *Object* `opts` parsed options
+ - *Array* `args` parsed arguments
+ - *Object* `res` actions result accumulator
+ It can return rejected promise by Cmd.reject (in case of error) + or any other value treated as result.
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.comp +Set custom additional completion for current option.
+**@param** *Function* `fn` completion generation function, + invoked in the context of command instance. + Accepts parameters:
+ - *Object* `opts` completion options
+ It can return promise or any other value treated as result.
+**@returns** *COA.Opt* `this` instance (for chainability) + +#### Opt.end +Finish chain for current option and return parent command instance.
+**@returns** *COA.Cmd* `parent` command + + +### Arg +Argument is a unnamed entity.
+From command line arguments passed as list of unnamed values. + +#### Arg.name +Set a canonical argument identifier to be used anywhere in text messages.
+**@param** *String* `_name` argument name
+**@returns** *COA.Arg* `this` instance (for chainability) + +#### Arg.title +Set a long description for argument to be used anywhere in text messages.
+**@param** *String* `_title` argument title
+**@returns** *COA.Arg* `this` instance (for chainability) + +#### Arg.arr +Makes an argument accepts multiple values.
+Otherwise, the value will be used by the latter passed.
+**@returns** *COA.Arg* `this` instance (for chainability) + +#### Arg.req +Makes an argument req.
+**@returns** *COA.Arg* `this` instance (for chainability) + +#### Arg.val +Set a validation (or value) function for argument.
+Value from command line passes through before becoming available from API.
+Using for validation and convertion simple types to any values.
+**@param** *Function* `_val` validating function, + invoked in the context of argument instance + and has one parameter with value from command line
+**@returns** *COA.Arg* `this` instance (for chainability) + +#### Arg.def +Set a default value for argument. +Default value passed through validation function as ordinary value.
+**@param** *Object* `_def`
+**@returns** *COA.Arg* `this` instance (for chainability) + +#### Arg.output +Make argument value outputing stream.
+It's add useful validation and shortcut for STDOUT.
+**@returns** *COA.Arg* `this` instance (for chainability) + +#### Arg.comp +Set custom additional completion for current argument.
+**@param** *Function* `fn` completion generation function, + invoked in the context of command instance. + Accepts parameters:
+ - *Object* `opts` completion options
+ It can return promise or any other value treated as result.
+**@returns** *COA.Arg* `this` instance (for chainability) + +#### Arg.end +Finish chain for current option and return parent command instance.
+**@returns** *COA.Cmd* `parent` command diff --git a/node_modules/coa/README.ru.md b/node_modules/coa/README.ru.md new file mode 100644 index 00000000..54a8bafe --- /dev/null +++ b/node_modules/coa/README.ru.md @@ -0,0 +1,316 @@ +# Command-Option-Argument +[![build status](https://secure.travis-ci.org/veged/coa.png)](http://travis-ci.org/veged/coa) + +## Что это? + +COA — парсер параметров командной строки, позволяющий извлечь максимум пользы от формального API вашей программы. +Как только вы опишете определение в терминах команд, параметров и аргументов, вы автоматически получите: + +* Справку для командной строки +* API для использования программы как модуля в COA-совместимых программах +* Автодополнение для командной строки + +### Прочие возможности + +* Широкий выбор настроек для параметров и аргументов, включая множественные значения, логические значения и обязательность параметров +* Возможность асинхронного исполнения команд, используя промисы (используется библиотека [Q](https://github.com/kriskowal/q)) +* Простота использования существующих команд как подмодулей для новых команд +* Комбинированная валидация и анализ сложных значений + +## Примеры + +````javascript +require('coa').Cmd() // декларация команды верхнего уровня + .name(process.argv[1]) // имя команды верхнего уровня, берем из имени программы + .title('Жутко полезная утилита для командной строки') // название для использования в справке и сообщениях + .helpful() // добавляем поддержку справки командной строки (-h, --help) + .opt() // добавляем параметр + .name('version') // имя параметра для использования в API + .title('Version') // текст для вывода в сообщениях + .short('v') // короткое имя параметра: -v + .long('version') // длинное имя параметра: --version + .flag() // параметр не требует ввода значения + .act(function(opts) { // действия при вызове аргумента + // результатом является вывод текстового сообщения + return JSON.parse(require('fs').readFileSync(__dirname + '/package.json')) + .version; + }) + .end() // завершаем определение параметра и возвращаемся к определению верхнего уровня + .cmd().name('subcommand').apply(require('./subcommand').COA).end() // загрузка подкоманды из модуля + .cmd() // добавляем еще одну подкоманду + .name('othercommand').title('Еще одна полезная подпрограмма').helpful() + .opt() + .name('input').title('input file, required') + .short('i').long('input') + .val(function(v) { // функция-валидатор, также может использоваться для трансформации значений параметров + return require('fs').createReadStream(v) }) + .req() // параметр является обязательным + .end() // завершаем определение параметра и возвращаемся к определению команды + .end() // завершаем определение подкоманды и возвращаемся к определению команды верхнего уровня + .run(process.argv.slice(2)); // разбираем process.argv и запускаем +```` + +````javascript +// subcommand.js +exports.COA = function() { + this + .title('Полезная подпрограмма').helpful() + .opt() + .name('output').title('output file') + .short('o').long('output') + .output() // использовать стандартную настройку для параметра вывода + .end() +}; +```` + +## API + +### Cmd +Команда — сущность верхнего уровня. У команды могут быть определены параметры и аргументы. + +#### Cmd.api +Возвращает объект, который можно использовать в других программах. Подкоманды являются методами этого объекта.
+**@returns** *{Object}* + +#### Cmd.name +Определяет канонический идентификатор команды, используемый в вызовах API.
+**@param** *String* `_name` имя команды
+**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов) + +#### Cmd.title +Определяет название команды, используемый в текстовых сообщениях.
+**@param** *String* `_title` название команды
+**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов) + +#### Cmd.cmd +Создает новую подкоманду или добавляет ранее определенную подкоманду к текущей команде.
+**@param** *COA.Cmd* `[cmd]` экземпляр ранее определенной подкоманды
+**@returns** *COA.Cmd* экземпляр новой или ранее определенной подкоманды + +#### Cmd.opt +Создает параметр для текущей команды.
+**@returns** *COA.Opt* `new` экземпляр параметра + +#### Cmd.arg +Создает аргумент для текущей команды.
+**@returns** *COA.Opt* `new` экземпляр аргумента + +#### Cmd.act +Добавляет (или создает) действие для текущей команды.
+**@param** *Function* `act` функция, + выполняемая в контексте экземпляра текущей команды + и принимающая следующие параметры:
+ - *Object* `opts` параметры команды
+ - *Array* `args` аргументы команды
+ - *Object* `res` объект-аккумулятор результатов
+ Функция может вернуть проваленный промис из Cmd.reject (в случае ошибки) + или любое другое значение, рассматриваемое как результат.
+**@param** *{Boolean}* [force=false] флаг, назначающий немедленное исполнение вместо добавления к списку существующих действий
+**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов) + +#### Cmd.apply +Исполняет функцию с переданными аргументами в контексте экземпляра текущей команды.
+**@param** *Function* `fn`
+**@param** *Array* `args`
+**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов) + +#### Cmd.comp +Назначает кастомную функцию автодополнения для текущей команды.
+**@param** *Function* `fn` функция-генератор автодополнения, + исполняемая в контексте текущей команды. + Принимает параметры:
+ - *Object* `opts` параметры
+ Может возвращать промис или любое другое значение, рассматриваемое как результат исполнения команды.
+**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов) + +#### Cmd.helpful +Ставит флаг поддержки справки командной строки, т.е. вызов команды с параметрами -h --help выводит справку по работе с командой.
+**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов) + +#### Cmd.completable +Добавляет поддержку автодополнения командной строки. Добавляется подкоманда "completion", которая выполняет все необходимые действия.
+Может быть добавлен только для главной команды.
+**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов) + +#### Cmd.usage +Возвращает текст справки по использованию команды для текущего экземпляра.
+**@returns** *String* `usage` Текст справки по использованию + +#### Cmd.run +Разбирает аргументы из значения, возвращаемого NodeJS process.argv, +и запускает текущую программу, т.е. вызывает process.exit после завершения +всех действий.
+**@param** *Array* `argv`
+**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов) + +#### Cmd.invoke +Исполняет переданную (или текущую) команду с указанными параметрами и аргументами.
+**@param** *String|Array* `cmds` подкоманда для исполнения (необязательно)
+**@param** *Object* `opts` параметры, передаваемые команде (необязательно)
+**@param** *Object* `args` аргументы, передаваемые команде (необязательно)
+**@returns** *Q.Promise* + +#### Cmd.reject +Проваливает промисы, возращенные в действиях.
+Используется в .act() для возврата с ошибкой.
+**@param** *Object* `reason` причина провала
+ Вы можете определить метод toString() и свойство toString() + объекта причины провала.
+**@returns** *Q.promise* проваленный промис + +#### Cmd.end +Завершает цепочку методов текущей подкоманды и возвращает экземпляр родительской команды.
+**@returns** *COA.Cmd* `parent` родительская команда + +### Opt +Параметр — именованная сущность. У параметра может быть определено короткое или длинное имя для использования из командной строки.
+**@namespace**
+**@class** Переданный параметр + +#### Opt.name +Определяет канонический идентификатор параметра, используемый в вызовах API.
+**@param** *String* `_name` имя параметра
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.title +Определяет описание для параметра, используемое в текстовых сообщениях.
+**@param** *String* `_title` название параметра
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.short +Назначает ключ для короткого имени параметра, передаваемого из командной строки с одинарным дефисом (например, `-v`).
+**@param** *String* `_short`
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.long +Назначает ключ для длинного имени параметра, передаваемого из командной строки с двойным дефисом (например, `--version`).
+**@param** *String* `_long`
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.flag +Помечает параметр как логический, т.е. параметр не имеющий значения.
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.arr +Помечает параметр как принимающий множественные значения.
+Иначе будет использовано последнее переданное значение параметра.
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.req +Помечает параметр как обязательный.
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.only +Интерпретирует параметр как команду, +т.е. программа будет завершена сразу после выполнения параметра.
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.val +Назначает функцию валидации (или трансформации значения) для значения параметра.
+Значение, полученное из командной строки, передается в функцию-валидатор прежде чем оно станет доступно из API.
+Используется для валидации и трансформации введенных данных.
+**@param** *Function* `_val` функция валидации, + исполняемая в контексте экземпляра параметра + и принимающая в качестве единственного параметра значение, полученное + из командной строки
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.def +Назначает значение параметра по умолчанию. Это значение также передается +в функцию валидации как обычное значение.
+**@param** *Object* `_def`
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.input +Помечает параметр как принимающий ввод пользователя.
+Позволяет использовать валидацию для STDIN.
+**@returns** *{COA.Opt}* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.output +Помечает параметр как вывод.
+Позволяет использовать валидацию для STDOUT.
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.act +Добавляет (или создает) действие для текущего параметра команды. +Это действие будет выполнено, если текущий параметр есть +в списке полученных параметров (с любым значением).
+**@param** *Function* `act` функция, выполняемая в контексте + экземпляра текущей команды и принимающая следующие параметры:
+ - *Object* `opts` параметры команды
+ - *Array* `args` аргументы команды
+ - *Object* `res` объект-аккумулятор результатов
+ Функция может вернуть проваленный промис из Cmd.reject (в случае ошибки) + или любое другое значение, рассматриваемое как результат.
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.comp +Назначает кастомную функцию автодополнения для текущей команды.
+**@param** *Function* `fn` функция-генератор автодоплнения, исполняемая в + контексте экземпляра команды. + Принимает параметры:
+ - *Object* `opts` параметры автодополнения
+ Может возвращать промис или любое другое значение, рассматриваемое как результат исполнения команды.
+**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов) + +#### Opt.end +Завершает цепочку методов текущего параметра и возвращает экземпляр родительской команды.
+**@returns** *COA.Cmd* `parent` родительская команда + + +### Arg +Аргумент — неименованная сущность.
+Аргументы передаются из командной строки как список неименованных значений. + +#### Arg.name +Определяет канонический идентификатор аргумента, используемый в вызовах API.
+**@param** *String* `_name` имя аргумента
+**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов) + +#### Arg.title +Определяет описание для аргумента, используемое в текстовых сообщениях.
+**@param** *String* `_title` описание аргумента
+**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов) + +#### Arg.arr +Помечает аргумент как принимающий множественные значения.
+Иначе будет использовано последнее переданное значение аргумента.
+**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов) + +#### Arg.req +Помечает аргумент как обязательный.
+**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов) + +#### Arg.val +Назначает функцию валидации (или трансформации значения) для аргумента.
+Значение, полученное из командной строки, передается в функцию-валидатор прежде чем оно станет доступно из API.
+Используется для валидации и трансформации введенных данных.
+**@param** *Function* `_val` функция валидации, + исполняемая в контексте экземпляра аргумента + и принимающая в качестве единственного параметра значение, полученное + из командной строки
+**@returns** *COA.Opt* `this` экземпляр аргумента (для поддержки цепочки методов) + +#### Arg.def +Назначает дефолтное значение для аргумента. Дефолтное значение передается +в функцию валидации как обычное значение.
+**@param** *Object* `_def`
+**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов) + +#### Arg.output +Помечает параметр как вывод.
+Позволяет назначить валидацию для STDOUT.
+**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов) + +#### Arg.comp +Назначает кастомную функцию автодополнения для текущего аргумента.
+**@param** *Function* `fn` функция-генератор автодоплнения, + исполняемая в контексте текущей команды. + Принимает параметры:
+ - *Object* `opts` параметры +Может возвращать промис или любое другое значение, рассматриваемое как результат исполнения команды.
+**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов) + +#### Arg.end +Завершает цепочку методов текущего аргумента и возвращает экземпляр родительской команды.
+**@returns** *COA.Cmd* `parent` родительская команда diff --git a/node_modules/coa/coverage/base.css b/node_modules/coa/coverage/base.css new file mode 100644 index 00000000..417c7adc --- /dev/null +++ b/node_modules/coa/coverage/base.css @@ -0,0 +1,212 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } + + +.medium .chart { border:1px solid #666; } +.medium .cover-fill { background: #666; } + +.cbranch-no { background: yellow !important; color: #111; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } +.medium { background: #eaeaea; } + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/node_modules/coa/coverage/coa/index.html b/node_modules/coa/coverage/coa/index.html new file mode 100644 index 00000000..1c0b7106 --- /dev/null +++ b/node_modules/coa/coverage/coa/index.html @@ -0,0 +1,93 @@ + + + + Code coverage report for coa + + + + + + + +
+
+

+ All files coa +

+
+
+ 100% + Statements + 1/1 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 1/1 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
index.js
100%1/1100%0/0100%0/0100%1/1
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/index.js.html b/node_modules/coa/coverage/coa/index.js.html new file mode 100644 index 00000000..a5da1dd3 --- /dev/null +++ b/node_modules/coa/coverage/coa/index.js.html @@ -0,0 +1,68 @@ + + + + Code coverage report for coa/index.js + + + + + + + +
+
+

+ All files / coa index.js +

+
+
+ 100% + Statements + 1/1 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 1/1 +
+
+
+
+

+
+
1 +21x + 
module.exports = require('./lib');
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/arg.js.html b/node_modules/coa/coverage/coa/lib/arg.js.html new file mode 100644 index 00000000..85b03aec --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/arg.js.html @@ -0,0 +1,239 @@ + + + + Code coverage report for coa/lib/arg.js + + + + + + + +
+
+

+ All files / coa/lib arg.js +

+
+
+ 100% + Statements + 16/16 +
+
+ 87.5% + Branches + 7/8 +
+
+ 100% + Functions + 6/6 +
+
+ 100% + Lines + 16/16 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +16x +  +16x +  +  +  +31x +  +31x +31x +  +  +  +31x +  +  +  +28x +  +  +  +2x +  +  +  +1x +  +1x +  +1x +  +1x +  +  +  +1x +  +  + 
'use strict';
+ 
+const
+    CoaParam = require('./coaparam'),
+    Color = require('./color');
+ 
+/**
+ * Argument
+ *
+ * Unnamed entity. From command line arguments passed as list of unnamed values.
+ *
+ * @class Arg
+ * @extends CoaParam
+ */
+module.exports = class Arg extends CoaParam {
+    /**
+     * @constructs
+     * @param {COA.Cmd} cmd - parent command
+     */
+    constructor(cmd) {
+        super(cmd);
+ 
+        this._cmd._args.push(this);
+    }
+ 
+    _saveVal(args, val) {
+        this._val && (val = this._val(val));
+ 
+        const name = this._name;
+        this._arr
+            ? (args[name] || (args[name] = [])).push(val)
+            : (args[name] = val);
+ 
+        return val;
+    }
+ 
+    _parse(arg, args) {
+        return this._saveVal(args, arg);
+    }
+ 
+    _checkParsed(opts, args) {
+        return !args.hasOwnProperty(this._name);
+    }
+ 
+    _usage() {
+        const res = [];
+ 
+        res.push(Color('lpurple', this._name.toUpperCase()), ' : ', this._title);
+ 
+        this._req && res.push(' ', Color('lred', '(required)'));
+ 
+        return res.join('');
+    }
+ 
+    _requiredText() {
+        return `Missing required argument:\n  ${this._usage()}`;
+    }
+};
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/cmd.js.html b/node_modules/coa/coverage/coa/lib/cmd.js.html new file mode 100644 index 00000000..03a50aca --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/cmd.js.html @@ -0,0 +1,1556 @@ + + + + Code coverage report for coa/lib/cmd.js + + + + + + + +
+
+

+ All files / coa/lib cmd.js +

+
+
+ 81.22% + Statements + 147/181 +
+
+ 71.64% + Branches + 96/134 +
+
+ 68.75% + Functions + 33/48 +
+
+ 82.53% + Lines + 137/166 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498  +  +  +1x +1x +1x +  +1x +  +1x +1x +1x +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +26x +  +26x +26x +26x +26x +26x +26x +26x +26x +  +  +  +21x +  +  +  +  +  +  +  +  +  +  +2x +2x +1x +  +  +2x +2x +1x +  +2x +  +  +  +28x +  +28x +  +  +  +  +28x +  +  +  +44x +  +  +  +  +  +  +  +  +  +12x +  +12x +  +  +12x +  +  +  +  +  +  +  +  +  +7x +  +  +  +  +  +  +  +  +  +  +16x +  +  +  +  +  +  +  +  +16x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +16x +  +16x +16x +  +16x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +5x +5x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +19x +19x +1x +  +18x +  +  +  +  +  +22x +  +21x +  +21x +41x +2x +  +  +  +35x +  +  +35x +35x +75x +  +75x +62x +62x +  +  +13x +13x +5x +2x +  +  +  +3x +3x +3x +3x +4x +4x +1x +  +  +  +5x +5x +5x +3x +  +2x +2x +2x +  +  +  +  +5x +  +  +  +13x +  +5x +  +  +27x +  +  +  +24x +24x +24x +24x +  +  +24x +47x +19x +19x +1x +1x +  +  +19x +19x +  +18x +  +17x +  +  +28x +28x +  +  +28x +30x +30x +  +28x +28x +  +  +  +20x +  +  +  +  +  +  +44x +14x +  +  +  +44x +  +  +  +4x +  +4x +3x +  +3x +  +  +  +  +3x +3x +  +  +3x +4x +  +  +  +4x +  +  +  +24x +24x +  +  +  +  +  +  +  +26x +22x +  +  +44x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +3x +3x +3x +3x +  +3x +1x +1x +1x +  +  +3x +3x +1x +  +2x +  +2x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +24x +  +  +  +5x +5x +  +  +  +  +  +1x + 
'use strict';
+ 
+const
+    UTIL = require('util'),
+    PATH = require('path'),
+    EOL = require('os').EOL,
+ 
+    Q = require('q'),
+ 
+    CoaObject = require('./coaobject'),
+    Color = require('./color'),
+    Opt = require('./opt'),
+    Arg = require('./arg'),
+    completion = require('./completion');
+ 
+/**
+ * Command
+ *
+ * Top level entity. Commands may have options and arguments.
+ *
+ * @namespace
+ * @class Cmd
+ * @extends CoaObject
+ */
+class Cmd extends CoaObject {
+    /**
+     * @constructs
+     * @param {COA.Cmd} [cmd] parent command
+     */
+    constructor(cmd) {
+        super(cmd);
+ 
+        this._parent(cmd);
+        this._cmds = [];
+        this._cmdsByName = {};
+        this._opts = [];
+        this._optsByKey = {};
+        this._args = [];
+        this._api = null;
+        this._ext = false;
+    }
+ 
+    static create(cmd) {
+        return new Cmd(cmd);
+    }
+ 
+    /**
+     * Returns object containing all its subcommands as methods
+     * to use from other programs.
+     *
+     * @returns {Object}
+     */
+    get api() {
+        // Need _this here because of passed arguments into _api
+        const _this = this;
+        this._api || (this._api = function () {
+            return _this.invoke.apply(_this, arguments);
+        });
+ 
+        const cmds = this._cmdsByName;
+        Object.keys(cmds).forEach((c) => {
+            this._api[c] = cmds[c].api;
+        });
+        return this._api;
+    }
+ 
+    _parent(cmd) {
+        this._cmd = cmd || this;
+ 
+        this.isRootCmd
+            || cmd._cmds.push(this)
+            && this._name
+            && (this._cmd._cmdsByName[this._name] = this);
+ 
+        return this;
+    }
+ 
+    get isRootCmd() {
+        return this._cmd === this;
+    }
+ 
+    /**
+     * Set a canonical command identifier to be used anywhere in the API.
+     *
+     * @param {String} name - command name
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    name(name) {
+        super.name(name);
+ 
+        this.isRootCmd
+            || (this._cmd._cmdsByName[name] = this);
+ 
+        return this;
+    }
+ 
+    /**
+     * Create new or add existing subcommand for current command.
+     *
+     * @param {COA.Cmd} [cmd] existing command instance
+     * @returns {COA.Cmd} new subcommand instance
+     */
+    cmd(cmd) {
+        return cmd?
+            cmd._parent(this)
+            : new Cmd(this);
+    }
+ 
+    /**
+     * Create option for current command.
+     *
+     * @returns {COA.Opt} new option instance
+     */
+    opt() {
+        return new Opt(this);
+    }
+ 
+    /**
+     * Create argument for current command.
+     *
+     * @returns {COA.Opt} new argument instance
+     */
+    arg() {
+        return new Arg(this);
+    }
+ 
+    /**
+     * Add (or set) action for current command.
+     *
+     * @param {Function} act - action function,
+     *         invoked in the context of command instance
+     *         and has the parameters:
+     *                 - {Object} opts - parsed options
+     *                 - {String[]} args - parsed arguments
+     *                 - {Object} res - actions result accumulator
+     *         It can return rejected promise by Cmd.reject (in case of error)
+     *         or any other value treated as result.
+     * @param {Boolean} [force=false] flag for set action instead add to existings
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    act(act, force) {
+        Iif(!act) return this;
+ 
+        (!this._act || force) && (this._act = []);
+        this._act.push(act);
+ 
+        return this;
+    }
+ 
+    /**
+     * Make command "helpful", i.e. add -h --help flags for print usage.
+     *
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    helpful() {
+        return this.opt()
+            .name('help')
+            .title('Help')
+            .short('h')
+            .long('help')
+            .flag()
+            .only()
+            .act(function() {
+                return this.usage();
+            })
+            .end();
+    }
+ 
+    /**
+     * Adds shell completion to command, adds "completion" subcommand,
+     * that makes all the magic.
+     * Must be called only on root command.
+     *
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    completable() {
+        return this.cmd()
+            .name('completion')
+            .apply(completion)
+            .end();
+    }
+ 
+    /**
+     * Allow command to be extendable by external node.js modules.
+     *
+     * @param {String} [pattern]  Pattern of node.js module to find subcommands at.
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    extendable(pattern) {
+        this._ext = pattern || true;
+        return this;
+    }
+ 
+    _exit(msg, code) {
+        return process.once('exit', function() {
+            msg && console.error(msg);
+            return process.exit(code || 0);
+        });
+    }
+ 
+    /**
+     * Build full usage text for current command instance.
+     *
+     * @returns {String} usage text
+     */
+    usage() {
+        const res = [];
+ 
+        this._title && res.push(this._fullTitle());
+ 
+        res.push('', 'Usage:');
+ 
+        this._cmds.length
+            && res.push([
+                '', '', Color('lred', this._fullName()), Color('lblue', 'COMMAND'),
+                Color('lgreen', '[OPTIONS]'), Color('lpurple', '[ARGS]')
+            ].join(' '));
+ 
+        (this._opts.length + this._args.length)
+            && res.push([
+                '', '', Color('lred', this._fullName()),
+                Color('lgreen', '[OPTIONS]'), Color('lpurple', '[ARGS]')
+            ].join(' '));
+ 
+        res.push(
+            this._usages(this._cmds, 'Commands'),
+            this._usages(this._opts, 'Options'),
+            this._usages(this._args, 'Arguments')
+        );
+ 
+        return res.join(EOL);
+    }
+ 
+    _usage() {
+        return Color('lblue', this._name) + ' : ' + this._title;
+    }
+ 
+    _usages(os, title) {
+        if(!os.length) return;
+ 
+        return ['', title + ':']
+            .concat(os.map(o => `  ${o._usage()}`))
+            .join(EOL);
+    }
+ 
+    _fullTitle() {
+        return `${this.isRootCmd? '' : this._cmd._fullTitle() + EOL}${this._title}`;
+    }
+ 
+    _fullName() {
+        return `${this.isRootCmd? '' : this._cmd._fullName() + ' '}${PATH.basename(this._name)}`;
+    }
+ 
+    _ejectOpt(opts, opt) {
+        const pos = opts.indexOf(opt);
+        if(pos === -1)
+            return;
+ 
+        return opts[pos]._arr?
+            opts[pos]
+            : opts.splice(pos, 1)[0];
+    }
+ 
+    _checkRequired(opts, args) {
+        if(this._opts.some(opt => opt._only && opt._name in opts)) return;
+ 
+        const all = this._opts.concat(this._args);
+        let i;
+        while(i = all.shift())
+            if(i._req && i._checkParsed(opts, args))
+                return this.reject(i._requiredText());
+    }
+ 
+    _parseCmd(argv, unparsed) {
+        unparsed || (unparsed = []);
+ 
+        let i,
+            optSeen = false;
+        while(i = argv.shift()) {
+            i.indexOf('-') || (optSeen = true);
+ 
+            if(optSeen || !/^\w[\w-_]*$/.test(i)) {
+                unparsed.push(i);
+                continue;
+            }
+ 
+            let pkg, cmd = this._cmdsByName[i];
+            if(!cmd && this._ext) {
+                if(typeof this._ext === 'string') {
+                    pkg = ~this._ext.indexOf('%s')?
+                        UTIL.format(this._ext, i)
+                        : this._ext + i;
+ 
+                } else Eif(this._ext === true) {
+                    pkg = i;
+                    let c = this;
+                    while(true) { // eslint-disable-line
+                        pkg = c._name + '-' + pkg;
+                        if(c.isRootCmd) break;
+                        c = c._cmd;
+                    }
+                }
+ 
+                const cmdDesc = tryCatch(() => require(pkg));
+                Eif(cmdDesc) {
+                    if(typeof cmdDesc === 'function') {
+                        this.cmd().name(i).apply(cmdDesc).end();
+ 
+                    } else Eif(typeof cmdDesc === 'object') {
+                        this.cmd(cmdDesc);
+                        cmdDesc.name(i);
+ 
+                    } else throw new Error('Error: Unsupported command declaration type, '
+                        + 'should be a function or COA.Cmd() object');
+ 
+                    cmd = this._cmdsByName[i];
+                }
+            }
+ 
+            if(cmd) return cmd._parseCmd(argv, unparsed);
+ 
+            unparsed.push(i);
+        }
+ 
+        return { cmd : this, argv : unparsed };
+    }
+ 
+    _parseOptsAndArgs(argv) {
+        const opts = {},
+            args = {},
+            nonParsedOpts = this._opts.concat(),
+            nonParsedArgs = this._args.concat();
+ 
+        let res, i;
+        while(i = argv.shift()) {
+            if(i !== '--' && i[0] === '-') {
+                const m = i.match(/^(--\w[\w-_]*)=(.*)$/);
+                if(m) {
+                    i = m[1];
+                    this._optsByKey[i]._flag || argv.unshift(m[2]);
+                }
+ 
+                const opt = this._ejectOpt(nonParsedOpts, this._optsByKey[i]);
+                if(!opt) return this.reject(`Unknown option: ${i}`);
+ 
+                if(Q.isRejected(res = opt._parse(argv, opts))) return res;
+ 
+                continue;
+            }
+ 
+            i === '--' && (i = argv.splice(0));
+            Array.isArray(i) || (i = [i]);
+ 
+            let a;
+            while(a = i.shift()) {
+                let arg = nonParsedArgs.shift();
+                if(!arg) return this.reject(`Unknown argument: ${a}`);
+ 
+                arg._arr && nonParsedArgs.unshift(arg);
+                Iif(Q.isRejected(res = arg._parse(a, args))) return res;
+            }
+        }
+ 
+        return {
+            opts : this._setDefaults(opts, nonParsedOpts),
+            args : this._setDefaults(args, nonParsedArgs)
+        };
+    }
+ 
+    _setDefaults(params, desc) {
+        for(const item of desc)
+            item._def
+                && !(item._name in params)
+                && item._saveVal(params, item._def);
+ 
+        return params;
+    }
+ 
+    _processParams(params, desc) {
+        const notExists = [];
+ 
+        for(const item of desc) {
+            const n = item._name;
+ 
+            Iif(!(n in params)) {
+                notExists.push(item);
+                continue;
+            }
+ 
+            const vals = [].concat(params[n]);
+            delete params[n];
+ 
+            let res;
+            for(const v of vals)
+                Iif(Q.isRejected(res = item._saveVal(params, v)))
+                    return res;
+        }
+ 
+        return this._setDefaults(params, notExists);
+    }
+ 
+    _parseArr(argv) {
+        return Q.when(this._parseCmd(argv), (p) =>
+            Q.when(p.cmd._parseOptsAndArgs(p.argv), (r) => ({
+                cmd : p.cmd,
+                opts : r.opts,
+                args : r.args
+            })));
+    }
+ 
+    _do(inputPromise) {
+        return Q.when(inputPromise, (input) => {
+            return [this._checkRequired]
+                .concat(input.cmd._act || [])
+                .reduce((res, act) =>
+                    Q.when(res, (prev) => act.call(input.cmd, input.opts, input.args, prev)),
+                    void 0);
+        });
+    }
+ 
+    /**
+     * Parse arguments from simple format like NodeJS process.argv
+     * and run ahead current program, i.e. call process.exit when all actions done.
+     *
+     * @param {String[]} argv - arguments
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    run(argv) {
+        argv || (argv = process.argv.slice(2));
+ 
+        const cb = (code) => (res) => res?
+            this._exit(res.stack || res.toString(), res.exitCode || code)
+            : this._exit();
+ 
+        Q.when(this.do(argv), cb(0), cb(1)).done();
+ 
+        return this;
+    }
+ 
+    /**
+     * Invoke specified (or current) command using provided
+     * options and arguments.
+     *
+     * @param {String|String[]} [cmds] - subcommand to invoke (optional)
+     * @param {Object} [opts] - command options (optional)
+     * @param {Object} [args] - command arguments (optional)
+     * @returns {Q.Promise}
+     */
+    invoke(cmds, opts, args) {
+        cmds || (cmds = []);
+        opts || (opts = {});
+        args || (args = {});
+        typeof cmds === 'string' && (cmds = cmds.split(' '));
+ 
+        if(arguments.length < 3 && !Array.isArray(cmds)) {
+            args = opts;
+            opts = cmds;
+            cmds = [];
+        }
+ 
+        return Q.when(this._parseCmd(cmds), (p) => {
+            if(p.argv.length)
+                return this.reject(`Unknown command: ${cmds.join(' ')}`);
+ 
+            return Q.all([this._processParams(opts, this._opts), this._processParams(args, this._args)])
+                .spread((_opts, _args) =>
+                    this._do({
+                        cmd : p.cmd,
+                        opts : _opts,
+                        args : _args
+                    })
+                    .fail((res) => (res && res.exitCode === 0)?
+                        res.toString()
+                        : this.reject(res)));
+        });
+    }
+}
+ 
+/**
+ * Convenient function to run command from tests.
+ *
+ * @param {String[]} argv - arguments
+ * @returns {Q.Promise}
+ */
+Cmd.prototype.do = function(argv) {
+    return this._do(this._parseArr(argv || []));
+};
+ 
+function tryCatch(fn, cb) {
+    try {
+        return fn();
+    } catch(e) {
+        return cb(e);
+    }
+}
+ 
+module.exports = Cmd;
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/coaobject.js.html b/node_modules/coa/coverage/coa/lib/coaobject.js.html new file mode 100644 index 00000000..32dfc7f5 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/coaobject.js.html @@ -0,0 +1,365 @@ + + + + Code coverage report for coa/lib/coaobject.js + + + + + + + +
+
+

+ All files / coa/lib coaobject.js +

+
+
+ 75% + Statements + 12/16 +
+
+ 50% + Branches + 1/2 +
+
+ 71.43% + Functions + 5/7 +
+
+ 75% + Lines + 12/16 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +58x +58x +58x +58x +  +  +  +  +  +  +  +  +  +44x +44x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +3x +  +  +  +3x +  +  +  +  +  +  +  +  +  +  +  +8x +  +  +  +  +  +  +  +38x +  +  + 
'use strict';
+ 
+const Q = require('q');
+ 
+/**
+ * COA Object
+ *
+ * Base class for all COA-related objects
+ *
+ * --------|-----|-----|-----
+ *         | Cmd | Opt | Arg
+ * --------|-----|-----|-----
+ *  name   | ✓   | ✓   | ✓
+ *  title  | ✓   | ✓   | ✓
+ *  comp   | ✓   | ✓   | ✓
+ *  reject | ✓   | ✓   | ✓
+ *  end    | ✓   | ✓   | ✓
+ *  apply  | ✓   | ✓   | ✓
+ *
+ * @class CoaObject
+ */
+module.exports = class CoaObject {
+    constructor(cmd) {
+        this._cmd = cmd;
+        this._name = null;
+        this._title = null;
+        this._comp = null;
+    }
+ 
+    /**
+     * Set a canonical identifier to be used anywhere in the API.
+     *
+     * @param {String} name - command, option or argument name
+     * @returns {COA.CoaObject} - this instance (for chainability)
+     */
+    name(name) {
+        this._name = name;
+        return this;
+    }
+ 
+    /**
+     * Set a long description to be used anywhere in text messages.
+     * @param {String} title - human readable entity title
+     * @returns {COA.CoaObject} - this instance (for chainability)
+     */
+    title(title) {
+        this._title = title;
+        return this;
+    }
+ 
+    /**
+     * Set custom additional completion for current object.
+     *
+     * @param {Function} comp - completion generation function,
+     *         invoked in the context of object instance.
+     *         Accepts parameters:
+     *                 - {Object} opts - completion options
+     *         It can return promise or any other value threated as a result.
+     * @returns {COA.CoaObject} - this instance (for chainability)
+     */
+    comp(comp) {
+        this._comp = comp;
+        return this;
+    }
+ 
+    /**
+     * Apply function with arguments in a context of object instance.
+     *
+     * @param {Function} fn - body
+     * @param {Array.<*>} args... - arguments
+     * @returns {COA.CoaObject} - this instance (for chainability)
+     */
+    apply(fn) {
+        arguments.length > 1?
+            fn.apply(this, [].slice.call(arguments, 1))
+            : fn.call(this);
+ 
+        return this;
+    }
+ 
+    /**
+     * Return reject of actions results promise with error code.
+     * Use in .act() for return with error.
+     * @param {Object} reason - reject reason
+     *         You can customize toString() method and exitCode property
+     *         of reason object.
+     * @returns {Q.promise} rejected promise
+     */
+    reject(reason) {
+        return Q.reject(reason);
+    }
+ 
+    /**
+     * Finish chain for current subcommand and return parent command instance.
+     * @returns {COA.Cmd} parent command
+     */
+    end() {
+        return this._cmd;
+    }
+};
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/coaparam.js.html b/node_modules/coa/coverage/coa/lib/coaparam.js.html new file mode 100644 index 00000000..b8bc9bd8 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/coaparam.js.html @@ -0,0 +1,440 @@ + + + + Code coverage report for coa/lib/coaparam.js + + + + + + + +
+
+

+ All files / coa/lib coaparam.js +

+
+
+ 51.61% + Statements + 16/31 +
+
+ 0% + Branches + 0/8 +
+
+ 55.56% + Functions + 5/9 +
+
+ 51.61% + Lines + 16/31 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126  +  +1x +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +32x +  +32x +32x +32x +32x +  +  +  +  +  +  +  +  +  +9x +9x +  +  +  +  +  +  +  +  +3x +3x +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
'use strict';
+ 
+const fs = require('fs');
+ 
+const CoaObject = require('./coaobject');
+ 
+/**
+ * COA Parameter
+ *
+ * Base class for options and arguments
+ *
+ * --------|-----|-----|-----
+ *         | Cmd | Opt | Arg
+ * --------|-----|-----|-----
+ *  arr    |     | ✓   | ✓
+ *  req    |     | ✓   | ✓
+ *  val    |     | ✓   | ✓
+ *  def    |     | ✓   | ✓
+ *  input  |     | ✓   | ✓
+ *  output |     | ✓   | ✓
+ *
+ * @class CoaParam
+ * @extends CoaObject
+ */
+module.exports = class CoaParam extends CoaObject {
+    constructor(cmd) {
+        super(cmd);
+ 
+        this._arr = false;
+        this._req = false;
+        this._val = undefined;
+        this._def = undefined;
+    }
+ 
+    /**
+     * Makes a param accepts multiple values.
+     * Otherwise, the value will be used by the latter passed.
+     *
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    arr() {
+        this._arr = true;
+        return this;
+    }
+ 
+    /**
+     * Makes a param required.
+     *
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    req() {
+        this._req = true;
+        return this;
+    }
+ 
+    /**
+     * Set a validation (or value) function for param.
+     * Value from command line passes through before becoming available from API.
+     * Using for validation and convertion simple types to any values.
+     *
+     * @param {Function} val - validating function,
+     *         invoked in the context of option instance
+     *         and has one parameter with value from command line.
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    val(val) {
+        this._val = val;
+        return this;
+    }
+ 
+    /**
+     * Set a default value for param.
+     * Default value passed through validation function as ordinary value.
+     *
+     * @param {*} def - default value of function generator
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    def(def) {
+        this._def = def;
+        return this;
+    }
+ 
+    /**
+     * Make option value inputting stream.
+     * It's add useful validation and shortcut for STDIN.
+     *
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    input() {
+        process.stdin.pause();
+        return this
+            .def(process.stdin)
+            .val(function(v) {
+                if(typeof v !== 'string')
+                    return v;
+ 
+                if(v === '-')
+                    return process.stdin;
+ 
+                const s = fs.createReadStream(v, { encoding : 'utf8' });
+                s.pause();
+                return s;
+            });
+    }
+ 
+    /**
+     * Make option value outputing stream.
+     * It's add useful validation and shortcut for STDOUT.
+     *
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    output() {
+        return this
+            .def(process.stdout)
+            .val(function(v) {
+                if(typeof v !== 'string')
+                    return v;
+ 
+                if(v === '-')
+                    return process.stdout;
+ 
+                return fs.createWriteStream(v, { encoding : 'utf8' });
+            });
+    }
+};
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/color.js.html b/node_modules/coa/coverage/coa/lib/color.js.html new file mode 100644 index 00000000..14531caf --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/color.js.html @@ -0,0 +1,131 @@ + + + + Code coverage report for coa/lib/color.js + + + + + + + +
+
+

+ All files / coa/lib color.js +

+
+
+ 100% + Statements + 3/3 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 1/1 +
+
+ 100% + Lines + 2/2 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x + 
'use strict';
+ 
+const colors = {
+    black : '30',
+    dgray : '1;30',
+    red : '31',
+    lred : '1;31',
+    green : '32',
+    lgreen : '1;32',
+    brown : '33',
+    yellow : '1;33',
+    blue : '34',
+    lblue : '1;34',
+    purple : '35',
+    lpurple : '1;35',
+    cyan : '36',
+    lcyan : '1;36',
+    lgray : '37',
+    white : '1;37'
+};
+ 
+module.exports = (c, str) => `\x1B[${colors[c]}m${str}\x1B[m`;
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/completion.js.html b/node_modules/coa/coverage/coa/lib/completion.js.html new file mode 100644 index 00000000..fb042e25 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/completion.js.html @@ -0,0 +1,593 @@ + + + + Code coverage report for coa/lib/completion.js + + + + + + + +
+
+

+ All files / coa/lib completion.js +

+
+
+ 11.27% + Statements + 8/71 +
+
+ 0% + Branches + 0/32 +
+
+ 0% + Functions + 0/14 +
+
+ 12.5% + Lines + 8/64 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177  +  +1x +1x +1x +  +1x +  +1x +1x +1x +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
'use strict';
+ 
+const constants = require('constants');
+const fs = require('fs');
+const path = require('path');
+ 
+const Q = require('q');
+ 
+const shell = require('./shell');
+const escape = shell.escape;
+const unescape = shell.unescape;
+ 
+/**
+ * Most of the code adopted from the npm package shell completion code.
+ * See https://github.com/isaacs/npm/blob/master/lib/completion.js
+ *
+ * @returns {COA.CoaObject}
+ */
+module.exports = function completion() {
+    return this
+        .title('Shell completion')
+        .helpful()
+        .arg()
+            .name('raw')
+            .title('Completion words')
+            .arr()
+            .end()
+        .act((opts, args) => {
+            if(process.platform === 'win32') {
+                const e = new Error('shell completion not supported on windows');
+                e.code = 'ENOTSUP';
+                e.errno = constants.ENOTSUP;
+                return this.reject(e);
+            }
+ 
+            // if the COMP_* isn't in the env, then just dump the script
+            if((process.env.COMP_CWORD == null)
+                || (process.env.COMP_LINE == null)
+                || (process.env.COMP_POINT == null)) {
+                return dumpScript(this._cmd._name);
+            }
+ 
+            console.error('COMP_LINE:  %s', process.env.COMP_LINE);
+            console.error('COMP_CWORD: %s', process.env.COMP_CWORD);
+            console.error('COMP_POINT: %s', process.env.COMP_POINT);
+            console.error('args: %j', args.raw);
+ 
+            // completion opts
+            opts = getOpts(args.raw);
+ 
+            // cmd
+            const parsed = this._cmd._parseCmd(opts.partialWords);
+            return Q.when(complete(parsed.cmd, parsed.opts), (compls) => {
+                console.error('filtered: %j', compls);
+                return console.log(compls.map(escape).join('\n'));
+            });
+        });
+};
+ 
+function dumpScript(name) {
+    const defer = Q.defer();
+ 
+    fs.readFile(path.resolve(__dirname, 'completion.sh'), 'utf8', function(err, d) {
+        if(err) return defer.reject(err);
+        d = d.replace(/{{cmd}}/g, path.basename(name)).replace(/^\#\!.*?\n/, '');
+ 
+        process.stdout.on('error', onError);
+        process.stdout.write(d, () => defer.resolve());
+    });
+ 
+    return defer.promise;
+ 
+    function onError(err) {
+        // Darwin is a real dick sometimes.
+        //
+        // This is necessary because the "source" or "." program in
+        // bash on OS X closes its file argument before reading
+        // from it, meaning that you get exactly 1 write, which will
+        // work most of the time, and will always raise an EPIPE.
+        //
+        // Really, one should not be tossing away EPIPE errors, or any
+        // errors, so casually. But, without this, `. <(cmd completion)`
+        // can never ever work on OS X.
+        if(err.errno !== constants.EPIPE) return defer.reject(err);
+        process.stdout.removeListener('error', onError);
+        return defer.resolve();
+    }
+}
+ 
+function getOpts(argv) {
+    // get the partial line and partial word, if the point isn't at the end
+    // ie, tabbing at: cmd foo b|ar
+    const line = process.env.COMP_LINE;
+    const w = +process.env.COMP_CWORD;
+    const point = +process.env.COMP_POINT;
+    const words = argv.map(unescape);
+    const word = words[w];
+    const partialLine = line.substr(0, point);
+    const partialWords = words.slice(0, w);
+ 
+    // figure out where in that last word the point is
+    let partialWord = argv[w] || '';
+    let i = partialWord.length;
+    while(partialWord.substr(0, i) !== partialLine.substr(-1 * i) && i > 0) i--;
+ 
+    partialWord = unescape(partialWord.substr(0, i));
+    partialWord && partialWords.push(partialWord);
+ 
+    return {
+        line,
+        w,
+        point,
+        words,
+        word,
+        partialLine,
+        partialWords,
+        partialWord
+    };
+}
+ 
+function complete(cmd, opts) {
+    let optWord, optPrefix,
+        compls = [];
+ 
+    // Complete on cmds
+    if(opts.partialWord.indexOf('-'))
+        compls = Object.keys(cmd._cmdsByName);
+        // Complete on required opts without '-' in last partial word
+        // (if required not already specified)
+        //
+        // Commented out because of uselessness:
+        // -b, --block suggest results in '-' on cmd line;
+        // next completion suggest all options, because of '-'
+        //.concat Object.keys(cmd._optsByKey).filter (v) -> cmd._optsByKey[v]._req
+    else {
+        // complete on opt values: --opt=| case
+        const m = opts.partialWord.match(/^(--\w[\w-_]*)=(.*)$/);
+        if(m) {
+            optWord = m[1];
+            optPrefix = optWord + '=';
+        } else
+            // complete on opts
+            // don't complete on opts in case of --opt=val completion
+            // TODO: don't complete on opts in case of unknown arg after commands
+            // TODO: complete only on opts with arr() or not already used
+            // TODO: complete only on full opts?
+            compls = Object.keys(cmd._optsByKey);
+    }
+ 
+    // complete on opt values: next arg case
+    opts.partialWords[opts.w - 1].indexOf('-') || (optWord = opts.partialWords[opts.w - 1]);
+ 
+    // complete on opt values: completion
+    let opt;
+    optWord
+        && (opt = cmd._optsByKey[optWord])
+        && !opt._flag
+        && opt._comp
+        && (compls = Q.join(compls,
+            Q.when(opt._comp(opts),
+                (c, o) => c.concat(o.map(v => (optPrefix || '') + v)))));
+ 
+    // TODO: complete on args values (context aware, custom completion?)
+ 
+    // custom completion on cmds
+    cmd._comp && (compls = Q.join(compls, Q.when(cmd._comp(opts)), (c, o) => c.concat(o)));
+ 
+    // TODO: context aware custom completion on cmds, opts and args
+    // (can depend on already entered values, especially options)
+ 
+    return Q.when(compls, complitions => {
+        console.error('partialWord: %s', opts.partialWord);
+        console.error('compls: %j', complitions);
+        return compls.filter((c) => c.indexOf(opts.partialWord) === 0);
+    });
+}
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/index.html b/node_modules/coa/coverage/coa/lib/index.html new file mode 100644 index 00000000..a9301282 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/index.html @@ -0,0 +1,197 @@ + + + + Code coverage report for coa/lib + + + + + + + +
+
+

+ All files coa/lib +

+
+
+ 68.17% + Statements + 257/377 +
+
+ 59.05% + Branches + 124/210 +
+
+ 65.35% + Functions + 66/101 +
+
+ 69.8% + Lines + 245/351 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
arg.js
100%16/1687.5%7/8100%6/6100%16/16
cmd.js
81.22%147/18171.64%96/13468.75%33/4882.53%137/166
coaobject.js
75%12/1650%1/271.43%5/775%12/16
coaparam.js
51.61%16/310%0/855.56%5/951.61%16/31
color.js
100%3/3100%0/0100%1/1100%2/2
completion.js
11.27%8/710%0/320%0/1412.5%8/64
index.js
100%5/5100%0/0100%0/0100%5/5
opt.js
91.84%45/4972.73%16/22100%14/1495.65%44/46
shell.js
100%5/5100%4/4100%2/2100%5/5
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/index.js.html b/node_modules/coa/coverage/coa/lib/index.js.html new file mode 100644 index 00000000..cfc7c0f0 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/index.js.html @@ -0,0 +1,107 @@ + + + + Code coverage report for coa/lib/index.js + + + + + + + +
+
+

+ All files / coa/lib index.js +

+
+
+ 100% + Statements + 5/5 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 5/5 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15  +1x +1x +1x +1x +  +1x +  +  +  +  +  +  +  + 
const
+    Cmd = require('./cmd'),
+    Opt = require('./opt'),
+    Arg = require('./arg'),
+    shell = require('./shell');
+ 
+module.exports = {
+    Cmd : Cmd.create,
+    Opt : Opt.create,
+    Arg : Arg.create,
+    classes : { Cmd, Opt, Arg },
+    shell,
+    require
+};
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/opt.js.html b/node_modules/coa/coverage/coa/lib/opt.js.html new file mode 100644 index 00000000..74e05c28 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/opt.js.html @@ -0,0 +1,524 @@ + + + + Code coverage report for coa/lib/opt.js + + + + + + + +
+
+

+ All files / coa/lib opt.js +

+
+
+ 91.84% + Statements + 45/49 +
+
+ 72.73% + Branches + 16/22 +
+
+ 100% + Functions + 14/14 +
+
+ 95.65% + Lines + 44/46 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154  +  +  +1x +  +1x +1x +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +16x +  +16x +16x +16x +16x +16x +  +  +  +  +  +  +  +  +  +7x +7x +7x +  +  +  +  +  +  +  +  +  +9x +9x +9x +  +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +1x +  +1x +1x +  +1x +2x +  +  +  +  +1x +  +  +  +20x +  +20x +20x +  +  +  +20x +  +  +  +18x +  +  +  +2x +  +  +  +1x +1x +  +1x +1x +1x +1x +  +  +1x +  +  +  +  +1x +  +1x +  +1x +  +  +  +1x +  +  + 
'use strict';
+ 
+const
+    Q = require('q'),
+ 
+    CoaParam = require('./coaparam'),
+    Color = require('./color');
+ 
+/**
+ * Option
+ *
+ * Named entity. Options may have short and long keys for use from command line.
+ *
+ * @namespace
+ * @class Opt
+ * @extends CoaParam
+ */
+module.exports = class Opt extends CoaParam {
+    /**
+     * @constructs
+     * @param {COA.Cmd} cmd - parent command
+     */
+    constructor(cmd) {
+        super(cmd);
+ 
+        this._short = null;
+        this._long = null;
+        this._flag = false;
+        this._only = false;
+        this._cmd._opts.push(this);
+    }
+ 
+    /**
+     * Set a short key for option to be used with one hyphen from command line.
+     *
+     * @param {String} short - short name
+     * @returns {COA.Opt} - this instance (for chainability)
+     */
+    short(short) {
+        this._short = short;
+        this._cmd._optsByKey[`-${short}`] = this;
+        return this;
+    }
+ 
+    /**
+     * Set a short key for option to be used with double hyphens from command line.
+     *
+     * @param {String} long - long name
+     * @returns {COA.Opt} - this instance (for chainability)
+     */
+    long(long) {
+        this._long = long;
+        this._cmd._optsByKey[`--${long}`] = this;
+        return this;
+    }
+ 
+    /**
+     * Make an option boolean, i.e. option without value.
+     *
+     * @returns {COA.Opt} - this instance (for chainability)
+     */
+    flag() {
+        this._flag = true;
+        return this;
+    }
+ 
+    /**
+     * Makes an option to act as a command,
+     * i.e. program will exit just after option action.
+     *
+     * @returns {COA.Opt} - this instance (for chainability)
+     */
+    only() {
+        this._only = true;
+        return this;
+    }
+ 
+    /**
+     * Add action for current option command.
+     * This action is performed if the current option
+     * is present in parsed options (with any value).
+     *
+     * @param {Function} act - action function,
+     *         invoked in the context of command instance
+     *         and has the parameters:
+     *                 - {Object} opts - parsed options
+     *                 - {Array} args - parsed arguments
+     *                 - {Object} res - actions result accumulator
+     *         It can return rejected promise by Cmd.reject (in case of error)
+     *         or any other value treated as result.
+     * @returns {COA.Opt} - this instance (for chainability)
+     */
+    act(act) {
+        this._cmd.act((opts) => {
+            Iif(!opts.hasOwnProperty(this._name)) return;
+ 
+            const res = act.apply(this._cmd, arguments);
+            Iif(!this._only) return res;
+ 
+            return Q.when(res, (out) => this._cmd.reject({
+                toString : () => out.toString(),
+                exitCode : 0
+            }));
+        });
+ 
+        return this;
+    }
+ 
+    _saveVal(opts, val) {
+        this._val && (val = this._val(val));
+ 
+        const name = this._name;
+        this._arr
+            ? (opts[name] || (opts[name] = [])).push(val)
+            : (opts[name] = val);
+ 
+        return val;
+    }
+ 
+    _parse(argv, opts) {
+        return this._saveVal(opts, this._flag ? true : argv.shift());
+    }
+ 
+    _checkParsed(opts) {
+        return !opts.hasOwnProperty(this._name);
+    }
+ 
+    _usage() {
+        const res = [],
+            nameStr = this._name.toUpperCase();
+ 
+        Eif(this._short) {
+            res.push('-', Color('lgreen', this._short));
+            this._flag || res.push(' ' + nameStr);
+            res.push(', ');
+        }
+ 
+        Iif(this._long) {
+            res.push('--', Color('green', this._long));
+            this._flag || res.push('=' + nameStr);
+        }
+ 
+        res.push(' : ', this._title);
+ 
+        this._req && res.push(' ', Color('lred', '(required)'));
+ 
+        return res.join('');
+    }
+ 
+    _requiredText() {
+        return `Missing required option:\n  ${this._usage()}`;
+    }
+};
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/shell.js.html b/node_modules/coa/coverage/coa/lib/shell.js.html new file mode 100644 index 00000000..b98935af --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/shell.js.html @@ -0,0 +1,107 @@ + + + + Code coverage report for coa/lib/shell.js + + + + + + + +
+
+

+ All files / coa/lib shell.js +

+
+
+ 100% + Statements + 5/5 +
+
+ 100% + Branches + 4/4 +
+
+ 100% + Functions + 2/2 +
+
+ 100% + Lines + 5/5 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +151x +  +  +2x +  +  +  +2x +  +  +  +6x +6x +  + 
module.exports = { escape, unescape };
+ 
+function unescape(w) {
+    w = w.charAt(0) === '"'
+        ? w.replace(/^"|([^\\])"$/g, '$1')
+        : w.replace(/\\ /g, ' ');
+ 
+    return w.replace(/\\("|'|\$|`|\\)/g, '$1');
+}
+ 
+function escape(w) {
+    w = w.replace(/(["'$`\\])/g,'\\$1');
+    return w.match(/\s+/) ? `"${w}"` : w;
+}
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/index.html b/node_modules/coa/coverage/index.html new file mode 100644 index 00000000..ee3d492f --- /dev/null +++ b/node_modules/coa/coverage/index.html @@ -0,0 +1,106 @@ + + + + Code coverage report for All files + + + + + + + +
+
+

+ All files +

+
+
+ 68.25% + Statements + 258/378 +
+
+ 59.05% + Branches + 124/210 +
+
+ 65.35% + Functions + 66/101 +
+
+ 69.89% + Lines + 246/352 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
coa
100%1/1100%0/0100%0/0100%1/1
coa/lib
68.17%257/37759.05%124/21065.35%66/10169.8%245/351
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/prettify.css b/node_modules/coa/coverage/prettify.css new file mode 100644 index 00000000..b317a7cd --- /dev/null +++ b/node_modules/coa/coverage/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/node_modules/coa/coverage/prettify.js b/node_modules/coa/coverage/prettify.js new file mode 100644 index 00000000..ef51e038 --- /dev/null +++ b/node_modules/coa/coverage/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/node_modules/coa/coverage/sort-arrow-sprite.png b/node_modules/coa/coverage/sort-arrow-sprite.png new file mode 100644 index 00000000..03f704a6 Binary files /dev/null and b/node_modules/coa/coverage/sort-arrow-sprite.png differ diff --git a/node_modules/coa/coverage/sorter.js b/node_modules/coa/coverage/sorter.js new file mode 100644 index 00000000..6c5034e4 --- /dev/null +++ b/node_modules/coa/coverage/sorter.js @@ -0,0 +1,158 @@ +var addSorting = (function () { + "use strict"; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { return document.querySelector('.coverage-summary'); } + // returns the thead element of the summary table + function getTableHeader() { return getTable().querySelector('thead tr'); } + // returns the tbody element of the summary table + function getTableBody() { return getTable().querySelector('tbody'); } + // returns the th element for nth column + function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function (a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function (a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function () { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i =0 ; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function () { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(cols); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/node_modules/coa/index.js b/node_modules/coa/index.js new file mode 100644 index 00000000..76c1c3a3 --- /dev/null +++ b/node_modules/coa/index.js @@ -0,0 +1 @@ +module.exports = require(process.env.COVER? './lib-cov' : './lib'); diff --git a/node_modules/coa/lib/arg.js b/node_modules/coa/lib/arg.js new file mode 100644 index 00000000..4444a8a5 --- /dev/null +++ b/node_modules/coa/lib/arg.js @@ -0,0 +1,175 @@ +// Generated by CoffeeScript 1.6.3 +var Arg, Cmd, Color, Opt; + +Color = require('./color').Color; + +Cmd = require('./cmd').Cmd; + +Opt = require('./opt').Opt; + +/** +Argument + +Unnamed entity. From command line arguments passed as list of unnamed values. +@namespace +@class Presents argument +*/ + + +exports.Arg = Arg = (function() { + /** + @constructs + @param {COA.Cmd} cmd parent command + */ + + function Arg(_cmd) { + this._cmd = _cmd; + this._cmd._args.push(this); + } + + /** + Set a canonical argument identifier to be used anywhere in text messages. + @param {String} _name argument name + @returns {COA.Arg} this instance (for chainability) + */ + + + Arg.prototype.name = Opt.prototype.name; + + /** + Set a long description for argument to be used anywhere in text messages. + @param {String} _title argument title + @returns {COA.Arg} this instance (for chainability) + */ + + + Arg.prototype.title = Cmd.prototype.title; + + /** + Makes an argument accepts multiple values. + Otherwise, the value will be used by the latter passed. + @returns {COA.Arg} this instance (for chainability) + */ + + + Arg.prototype.arr = Opt.prototype.arr; + + /** + Makes an argument required. + @returns {COA.Arg} this instance (for chainability) + */ + + + Arg.prototype.req = Opt.prototype.req; + + /** + Set a validation (or value) function for argument. + Value from command line passes through before becoming available from API. + Using for validation and convertion simple types to any values. + @param {Function} _val validating function, + invoked in the context of argument instance + and has one parameter with value from command line + @returns {COA.Arg} this instance (for chainability) + */ + + + Arg.prototype.val = Opt.prototype.val; + + /** + Set a default value for argument. + Default value passed through validation function as ordinary value. + @param {Object} _def + @returns {COA.Arg} this instance (for chainability) + */ + + + Arg.prototype.def = Opt.prototype.def; + + /** + Set custom additional completion for current argument. + @param {Function} completion generation function, + invoked in the context of argument instance. + Accepts parameters: + - {Object} opts completion options + It can return promise or any other value treated as result. + @returns {COA.Arg} this instance (for chainability) + */ + + + Arg.prototype.comp = Cmd.prototype.comp; + + /** + Make argument value inputting stream. + It's add useful validation and shortcut for STDIN. + @returns {COA.Arg} this instance (for chainability) + */ + + + Arg.prototype.input = Opt.prototype.input; + + /** + Make argument value outputing stream. + It's add useful validation and shortcut for STDOUT. + @returns {COA.Arg} this instance (for chainability) + */ + + + Arg.prototype.output = Opt.prototype.output; + + Arg.prototype._parse = function(arg, args) { + return this._saveVal(args, arg); + }; + + Arg.prototype._saveVal = Opt.prototype._saveVal; + + Arg.prototype._checkParsed = function(opts, args) { + return !args.hasOwnProperty(this._name); + }; + + Arg.prototype._usage = function() { + var res; + res = []; + res.push(Color('lpurple', this._name.toUpperCase()), ' : ', this._title); + if (this._req) { + res.push(' ', Color('lred', '(required)')); + } + return res.join(''); + }; + + Arg.prototype._requiredText = function() { + return 'Missing required argument:\n ' + this._usage(); + }; + + /** + Return rejected promise with error code. + Use in .val() for return with error. + @param {Object} reject reason + You can customize toString() method and exitCode property + of reason object. + @returns {Q.promise} rejected promise + */ + + + Arg.prototype.reject = Cmd.prototype.reject; + + /** + Finish chain for current option and return parent command instance. + @returns {COA.Cmd} parent command + */ + + + Arg.prototype.end = Cmd.prototype.end; + + /** + Apply function with arguments in context of arg instance. + @param {Function} fn + @param {Array} args + @returns {COA.Arg} this instance (for chainability) + */ + + + Arg.prototype.apply = Cmd.prototype.apply; + + return Arg; + +})(); diff --git a/node_modules/coa/lib/cmd.js b/node_modules/coa/lib/cmd.js new file mode 100644 index 00000000..b53c2541 --- /dev/null +++ b/node_modules/coa/lib/cmd.js @@ -0,0 +1,605 @@ +// Generated by CoffeeScript 1.6.3 +var Cmd, Color, PATH, Q, UTIL, + __slice = [].slice; + +UTIL = require('util'); + +PATH = require('path'); + +Color = require('./color').Color; + +Q = require('q'); + +/** +Command + +Top level entity. Commands may have options and arguments. +@namespace +@class Presents command +*/ + + +exports.Cmd = Cmd = (function() { + /** + @constructs + @param {COA.Cmd} [cmd] parent command + */ + + function Cmd(cmd) { + if (!(this instanceof Cmd)) { + return new Cmd(cmd); + } + this._parent(cmd); + this._cmds = []; + this._cmdsByName = {}; + this._opts = []; + this._optsByKey = {}; + this._args = []; + this._ext = false; + } + + Cmd.get = function(propertyName, func) { + return Object.defineProperty(this.prototype, propertyName, { + configurable: true, + enumerable: true, + get: func + }); + }; + + /** + Returns object containing all its subcommands as methods + to use from other programs. + @returns {Object} + */ + + + Cmd.get('api', function() { + var c, _fn, + _this = this; + if (!this._api) { + this._api = function() { + return _this.invoke.apply(_this, arguments); + }; + } + _fn = function(c) { + return _this._api[c] = _this._cmdsByName[c].api; + }; + for (c in this._cmdsByName) { + _fn(c); + } + return this._api; + }); + + Cmd.prototype._parent = function(cmd) { + this._cmd = cmd || this; + if (cmd) { + cmd._cmds.push(this); + if (this._name) { + this._cmd._cmdsByName[this._name] = this; + } + } + return this; + }; + + /** + Set a canonical command identifier to be used anywhere in the API. + @param {String} _name command name + @returns {COA.Cmd} this instance (for chainability) + */ + + + Cmd.prototype.name = function(_name) { + this._name = _name; + if (this._cmd !== this) { + this._cmd._cmdsByName[_name] = this; + } + return this; + }; + + /** + Set a long description for command to be used anywhere in text messages. + @param {String} _title command title + @returns {COA.Cmd} this instance (for chainability) + */ + + + Cmd.prototype.title = function(_title) { + this._title = _title; + return this; + }; + + /** + Create new or add existing subcommand for current command. + @param {COA.Cmd} [cmd] existing command instance + @returns {COA.Cmd} new subcommand instance + */ + + + Cmd.prototype.cmd = function(cmd) { + if (cmd) { + return cmd._parent(this); + } else { + return new Cmd(this); + } + }; + + /** + Create option for current command. + @returns {COA.Opt} new option instance + */ + + + Cmd.prototype.opt = function() { + return new (require('./opt').Opt)(this); + }; + + /** + Create argument for current command. + @returns {COA.Opt} new argument instance + */ + + + Cmd.prototype.arg = function() { + return new (require('./arg').Arg)(this); + }; + + /** + Add (or set) action for current command. + @param {Function} act action function, + invoked in the context of command instance + and has the parameters: + - {Object} opts parsed options + - {Array} args parsed arguments + - {Object} res actions result accumulator + It can return rejected promise by Cmd.reject (in case of error) + or any other value treated as result. + @param {Boolean} [force=false] flag for set action instead add to existings + @returns {COA.Cmd} this instance (for chainability) + */ + + + Cmd.prototype.act = function(act, force) { + if (!act) { + return this; + } + if (!force && this._act) { + this._act.push(act); + } else { + this._act = [act]; + } + return this; + }; + + /** + Set custom additional completion for current command. + @param {Function} completion generation function, + invoked in the context of command instance. + Accepts parameters: + - {Object} opts completion options + It can return promise or any other value treated as result. + @returns {COA.Cmd} this instance (for chainability) + */ + + + Cmd.prototype.comp = function(_comp) { + this._comp = _comp; + return this; + }; + + /** + Apply function with arguments in context of command instance. + @param {Function} fn + @param {Array} args + @returns {COA.Cmd} this instance (for chainability) + */ + + + Cmd.prototype.apply = function() { + var args, fn; + fn = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + fn.apply(this, args); + return this; + }; + + /** + Make command "helpful", i.e. add -h --help flags for print usage. + @returns {COA.Cmd} this instance (for chainability) + */ + + + Cmd.prototype.helpful = function() { + return this.opt().name('help').title('Help').short('h').long('help').flag().only().act(function() { + return this.usage(); + }).end(); + }; + + /** + Adds shell completion to command, adds "completion" subcommand, + that makes all the magic. + Must be called only on root command. + @returns {COA.Cmd} this instance (for chainability) + */ + + + Cmd.prototype.completable = function() { + return this.cmd().name('completion').apply(require('./completion')).end(); + }; + + /** + Allow command to be extendable by external node.js modules. + @param {String} [pattern] Pattern of node.js module to find subcommands at. + @returns {COA.Cmd} this instance (for chainability) + */ + + + Cmd.prototype.extendable = function(pattern) { + this._ext = pattern || true; + return this; + }; + + Cmd.prototype._exit = function(msg, code) { + return process.once('exit', function() { + if (msg) { + console.error(msg); + } + return process.exit(code || 0); + }); + }; + + /** + Build full usage text for current command instance. + @returns {String} usage text + */ + + + Cmd.prototype.usage = function() { + var res; + res = []; + if (this._title) { + res.push(this._fullTitle()); + } + res.push('', 'Usage:'); + if (this._cmds.length) { + res.push(['', '', Color('lred', this._fullName()), Color('lblue', 'COMMAND'), Color('lgreen', '[OPTIONS]'), Color('lpurple', '[ARGS]')].join(' ')); + } + if (this._opts.length + this._args.length) { + res.push(['', '', Color('lred', this._fullName()), Color('lgreen', '[OPTIONS]'), Color('lpurple', '[ARGS]')].join(' ')); + } + res.push(this._usages(this._cmds, 'Commands'), this._usages(this._opts, 'Options'), this._usages(this._args, 'Arguments')); + return res.join('\n'); + }; + + Cmd.prototype._usage = function() { + return Color('lblue', this._name) + ' : ' + this._title; + }; + + Cmd.prototype._usages = function(os, title) { + var o, res, _i, _len; + if (!os.length) { + return; + } + res = ['', title + ':']; + for (_i = 0, _len = os.length; _i < _len; _i++) { + o = os[_i]; + res.push(' ' + o._usage()); + } + return res.join('\n'); + }; + + Cmd.prototype._fullTitle = function() { + return (this._cmd === this ? '' : this._cmd._fullTitle() + '\n') + this._title; + }; + + Cmd.prototype._fullName = function() { + return (this._cmd === this ? '' : this._cmd._fullName() + ' ') + PATH.basename(this._name); + }; + + Cmd.prototype._ejectOpt = function(opts, opt) { + var pos; + if ((pos = opts.indexOf(opt)) >= 0) { + if (opts[pos]._arr) { + return opts[pos]; + } else { + return opts.splice(pos, 1)[0]; + } + } + }; + + Cmd.prototype._checkRequired = function(opts, args) { + var all, i; + if (!(this._opts.filter(function(o) { + return o._only && o._name in opts; + })).length) { + all = this._opts.concat(this._args); + while (i = all.shift()) { + if (i._req && i._checkParsed(opts, args)) { + return this.reject(i._requiredText()); + } + } + } + }; + + Cmd.prototype._parseCmd = function(argv, unparsed) { + var c, cmd, cmdDesc, e, i, optSeen, pkg; + if (unparsed == null) { + unparsed = []; + } + argv = argv.concat(); + optSeen = false; + while (i = argv.shift()) { + if (!i.indexOf('-')) { + optSeen = true; + } + if (!optSeen && /^\w[\w-_]*$/.test(i)) { + cmd = this._cmdsByName[i]; + if (!cmd && this._ext) { + if (typeof this._ext === 'string') { + if (~this._ext.indexOf('%s')) { + pkg = UTIL.format(this._ext, i); + } else { + pkg = this._ext + i; + } + } else if (this._ext === true) { + pkg = i; + c = this; + while (true) { + pkg = c._name + '-' + pkg; + if (c._cmd === c) { + break; + } + c = c._cmd; + } + } + try { + cmdDesc = require(pkg); + } catch (_error) { + e = _error; + } + if (cmdDesc) { + if (typeof cmdDesc === 'function') { + this.cmd().name(i).apply(cmdDesc).end(); + } else if (typeof cmdDesc === 'object') { + this.cmd(cmdDesc); + cmdDesc.name(i); + } else { + throw new Error('Error: Unsupported command declaration type, ' + 'should be function or COA.Cmd() object'); + } + cmd = this._cmdsByName[i]; + } + } + if (cmd) { + return cmd._parseCmd(argv, unparsed); + } + } + unparsed.push(i); + } + return { + cmd: this, + argv: unparsed + }; + }; + + Cmd.prototype._parseOptsAndArgs = function(argv) { + var a, arg, args, i, m, nonParsedArgs, nonParsedOpts, opt, opts, res; + opts = {}; + args = {}; + nonParsedOpts = this._opts.concat(); + nonParsedArgs = this._args.concat(); + while (i = argv.shift()) { + if (i !== '--' && !i.indexOf('-')) { + if (m = i.match(/^(--\w[\w-_]*)=(.*)$/)) { + i = m[1]; + if (!this._optsByKey[i]._flag) { + argv.unshift(m[2]); + } + } + if (opt = this._ejectOpt(nonParsedOpts, this._optsByKey[i])) { + if (Q.isRejected(res = opt._parse(argv, opts))) { + return res; + } + } else { + return this.reject("Unknown option: " + i); + } + } else { + if (i === '--') { + i = argv.splice(0); + } + i = Array.isArray(i) ? i : [i]; + while (a = i.shift()) { + if (arg = nonParsedArgs.shift()) { + if (arg._arr) { + nonParsedArgs.unshift(arg); + } + if (Q.isRejected(res = arg._parse(a, args))) { + return res; + } + } else { + return this.reject("Unknown argument: " + a); + } + } + } + } + return { + opts: this._setDefaults(opts, nonParsedOpts), + args: this._setDefaults(args, nonParsedArgs) + }; + }; + + Cmd.prototype._setDefaults = function(params, desc) { + var i, _i, _len; + for (_i = 0, _len = desc.length; _i < _len; _i++) { + i = desc[_i]; + if (!(i._name in params) && '_def' in i) { + i._saveVal(params, i._def); + } + } + return params; + }; + + Cmd.prototype._processParams = function(params, desc) { + var i, n, notExists, res, v, vals, _i, _j, _len, _len1; + notExists = []; + for (_i = 0, _len = desc.length; _i < _len; _i++) { + i = desc[_i]; + n = i._name; + if (!(n in params)) { + notExists.push(i); + continue; + } + vals = params[n]; + delete params[n]; + if (!Array.isArray(vals)) { + vals = [vals]; + } + for (_j = 0, _len1 = vals.length; _j < _len1; _j++) { + v = vals[_j]; + if (Q.isRejected(res = i._saveVal(params, v))) { + return res; + } + } + } + return this._setDefaults(params, notExists); + }; + + Cmd.prototype._parseArr = function(argv) { + return Q.when(this._parseCmd(argv), function(p) { + return Q.when(p.cmd._parseOptsAndArgs(p.argv), function(r) { + return { + cmd: p.cmd, + opts: r.opts, + args: r.args + }; + }); + }); + }; + + Cmd.prototype._do = function(input) { + var _this = this; + return Q.when(input, function(input) { + var cmd; + cmd = input.cmd; + return [_this._checkRequired].concat(cmd._act || []).reduce(function(res, act) { + return Q.when(res, function(res) { + return act.call(cmd, input.opts, input.args, res); + }); + }, void 0); + }); + }; + + /** + Parse arguments from simple format like NodeJS process.argv + and run ahead current program, i.e. call process.exit when all actions done. + @param {Array} argv + @returns {COA.Cmd} this instance (for chainability) + */ + + + Cmd.prototype.run = function(argv) { + var cb, + _this = this; + if (argv == null) { + argv = process.argv.slice(2); + } + cb = function(code) { + return function(res) { + var _ref, _ref1; + if (res) { + return _this._exit((_ref = res.stack) != null ? _ref : res.toString(), (_ref1 = res.exitCode) != null ? _ref1 : code); + } else { + return _this._exit(); + } + }; + }; + Q.when(this["do"](argv), cb(0), cb(1)).done(); + return this; + }; + + /** + Convenient function to run command from tests. + @param {Array} argv + @returns {Q.Promise} + */ + + + Cmd.prototype["do"] = function(argv) { + return this._do(this._parseArr(argv || [])); + }; + + /** + Invoke specified (or current) command using provided + options and arguments. + @param {String|Array} cmds subcommand to invoke (optional) + @param {Object} opts command options (optional) + @param {Object} args command arguments (optional) + @returns {Q.Promise} + */ + + + Cmd.prototype.invoke = function(cmds, opts, args) { + var _this = this; + if (cmds == null) { + cmds = []; + } + if (opts == null) { + opts = {}; + } + if (args == null) { + args = {}; + } + if (typeof cmds === 'string') { + cmds = cmds.split(' '); + } + if (arguments.length < 3) { + if (!Array.isArray(cmds)) { + args = opts; + opts = cmds; + cmds = []; + } + } + return Q.when(this._parseCmd(cmds), function(p) { + if (p.argv.length) { + return _this.reject("Unknown command: " + cmds.join(' ')); + } + return Q.all([_this._processParams(opts, _this._opts), _this._processParams(args, _this._args)]).spread(function(opts, args) { + return _this._do({ + cmd: p.cmd, + opts: opts, + args: args + }).fail(function(res) { + if (res && res.exitCode === 0) { + return res.toString(); + } else { + return _this.reject(res); + } + }); + }); + }); + }; + + /** + Return reject of actions results promise with error code. + Use in .act() for return with error. + @param {Object} reject reason + You can customize toString() method and exitCode property + of reason object. + @returns {Q.promise} rejected promise + */ + + + Cmd.prototype.reject = function(reason) { + return Q.reject(reason); + }; + + /** + Finish chain for current subcommand and return parent command instance. + @returns {COA.Cmd} parent command + */ + + + Cmd.prototype.end = function() { + return this._cmd; + }; + + return Cmd; + +})(); diff --git a/node_modules/coa/lib/color.js b/node_modules/coa/lib/color.js new file mode 100644 index 00000000..7271c8c8 --- /dev/null +++ b/node_modules/coa/lib/color.js @@ -0,0 +1,25 @@ +// Generated by CoffeeScript 1.6.3 +var colors; + +colors = { + black: '30', + dgray: '1;30', + red: '31', + lred: '1;31', + green: '32', + lgreen: '1;32', + brown: '33', + yellow: '1;33', + blue: '34', + lblue: '1;34', + purple: '35', + lpurple: '1;35', + cyan: '36', + lcyan: '1;36', + lgray: '37', + white: '1;37' +}; + +exports.Color = function(c, str) { + return ['\x1B[', colors[c], 'm', str, '\x1B[m'].join(''); +}; diff --git a/node_modules/coa/lib/completion.js b/node_modules/coa/lib/completion.js new file mode 100644 index 00000000..a4b1edcb --- /dev/null +++ b/node_modules/coa/lib/completion.js @@ -0,0 +1,134 @@ +// Generated by CoffeeScript 1.6.3 +/** +Most of the code adopted from the npm package shell completion code. +See https://github.com/isaacs/npm/blob/master/lib/completion.js +*/ + +var Q, complete, dumpScript, escape, getOpts, unescape; + +Q = require('q'); + +escape = require('./shell').escape; + +unescape = require('./shell').unescape; + +module.exports = function() { + return this.title('Shell completion').helpful().arg().name('raw').title('Completion words').arr().end().act(function(opts, args) { + var argv, cmd, e, _ref; + if (process.platform === 'win32') { + e = new Error('shell completion not supported on windows'); + e.code = 'ENOTSUP'; + e.errno = require('constants').ENOTSUP; + return this.reject(e); + } + if ((process.env.COMP_CWORD == null) || (process.env.COMP_LINE == null) || (process.env.COMP_POINT == null)) { + return dumpScript(this._cmd._name); + } + console.error('COMP_LINE: %s', process.env.COMP_LINE); + console.error('COMP_CWORD: %s', process.env.COMP_CWORD); + console.error('COMP_POINT: %s', process.env.COMP_POINT); + console.error('args: %j', args.raw); + opts = getOpts(args.raw); + _ref = this._cmd._parseCmd(opts.partialWords), cmd = _ref.cmd, argv = _ref.argv; + return Q.when(complete(cmd, opts), function(compls) { + console.error('filtered: %j', compls); + return console.log(compls.map(escape).join('\n')); + }); + }); +}; + +dumpScript = function(name) { + var defer, fs, path; + fs = require('fs'); + path = require('path'); + defer = Q.defer(); + fs.readFile(path.resolve(__dirname, 'completion.sh'), 'utf8', function(err, d) { + var onError; + if (err) { + return defer.reject(err); + } + d = d.replace(/{{cmd}}/g, path.basename(name)).replace(/^\#\!.*?\n/, ''); + onError = function(err) { + if (err.errno === require('constants').EPIPE) { + process.stdout.removeListener('error', onError); + return defer.resolve(); + } else { + return defer.reject(err); + } + }; + process.stdout.on('error', onError); + return process.stdout.write(d, function() { + return defer.resolve(); + }); + }); + return defer.promise; +}; + +getOpts = function(argv) { + var i, line, partialLine, partialWord, partialWords, point, w, word, words; + line = process.env.COMP_LINE; + w = +process.env.COMP_CWORD; + point = +process.env.COMP_POINT; + words = argv.map(unescape); + word = words[w]; + partialLine = line.substr(0, point); + partialWords = words.slice(0, w); + partialWord = argv[w] || ''; + i = partialWord.length; + while (partialWord.substr(0, i) !== partialLine.substr(-1 * i) && i > 0) { + i--; + } + partialWord = unescape(partialWord.substr(0, i)); + if (partialWord) { + partialWords.push(partialWord); + } + return { + line: line, + w: w, + point: point, + words: words, + word: word, + partialLine: partialLine, + partialWords: partialWords, + partialWord: partialWord + }; +}; + +complete = function(cmd, opts) { + var compls, m, o, opt, optPrefix, optWord; + compls = []; + if (opts.partialWord.indexOf('-')) { + compls = Object.keys(cmd._cmdsByName); + } else { + if (m = opts.partialWord.match(/^(--\w[\w-_]*)=(.*)$/)) { + optWord = m[1]; + optPrefix = optWord + '='; + } else { + compls = Object.keys(cmd._optsByKey); + } + } + if (!(o = opts.partialWords[opts.w - 1]).indexOf('-')) { + optWord = o; + } + if (optWord && (opt = cmd._optsByKey[optWord])) { + if (!opt._flag && opt._comp) { + compls = Q.join(compls, Q.when(opt._comp(opts), function(c, o) { + return c.concat(o.map(function(v) { + return (optPrefix || '') + v; + })); + })); + } + } + if (cmd._comp) { + compls = Q.join(compls, Q.when(cmd._comp(opts)), function(c, o) { + return c.concat(o); + }); + } + return Q.when(compls, function(compls) { + console.error('partialWord: %s', opts.partialWord); + console.error('compls: %j', compls); + return compls.filter(function(c) { + return c.indexOf(opts.partialWord) === 0; + }); + }); +}; diff --git a/node_modules/coa/lib/completion.sh b/node_modules/coa/lib/completion.sh new file mode 100644 index 00000000..6d15c871 --- /dev/null +++ b/node_modules/coa/lib/completion.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +###-begin-{{cmd}}-completion-### +# +# {{cmd}} command completion script +# +# Installation: {{cmd}} completion >> ~/.bashrc (or ~/.zshrc) +# Or, maybe: {{cmd}} completion > /usr/local/etc/bash_completion.d/{{cmd}} +# + +COMP_WORDBREAKS=${COMP_WORDBREAKS/=/} +COMP_WORDBREAKS=${COMP_WORDBREAKS/@/} +export COMP_WORDBREAKS + +if complete &>/dev/null; then + _{{cmd}}_completion () { + local si="$IFS" + IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \ + COMP_LINE="$COMP_LINE" \ + COMP_POINT="$COMP_POINT" \ + {{cmd}} completion -- "${COMP_WORDS[@]}" \ + 2>/dev/null)) || return $? + IFS="$si" + } + complete -F _{{cmd}}_completion {{cmd}} +elif compctl &>/dev/null; then + _{{cmd}}_completion () { + local cword line point words si + read -Ac words + read -cn cword + let cword-=1 + read -l line + read -ln point + si="$IFS" + IFS=$'\n' reply=($(COMP_CWORD="$cword" \ + COMP_LINE="$line" \ + COMP_POINT="$point" \ + {{cmd}} completion -- "${words[@]}" \ + 2>/dev/null)) || return $? + IFS="$si" + } + compctl -K _{{cmd}}_completion {{cmd}} +fi +###-end-{{cmd}}-completion-### diff --git a/node_modules/coa/lib/index.js b/node_modules/coa/lib/index.js new file mode 100644 index 00000000..05b89221 --- /dev/null +++ b/node_modules/coa/lib/index.js @@ -0,0 +1,10 @@ +// Generated by CoffeeScript 1.6.3 +exports.Cmd = require('./cmd').Cmd; + +exports.Opt = require('./cmd').Opt; + +exports.Arg = require('./cmd').Arg; + +exports.shell = require('./shell'); + +exports.require = require; diff --git a/node_modules/coa/lib/opt.js b/node_modules/coa/lib/opt.js new file mode 100644 index 00000000..9aaca543 --- /dev/null +++ b/node_modules/coa/lib/opt.js @@ -0,0 +1,338 @@ +// Generated by CoffeeScript 1.6.3 +var Cmd, Color, Opt, Q, fs; + +fs = require('fs'); + +Q = require('q'); + +Color = require('./color').Color; + +Cmd = require('./cmd').Cmd; + +/** +Option + +Named entity. Options may have short and long keys for use from command line. +@namespace +@class Presents option +*/ + + +exports.Opt = Opt = (function() { + /** + @constructs + @param {COA.Cmd} cmd parent command + */ + + function Opt(_cmd) { + this._cmd = _cmd; + this._cmd._opts.push(this); + } + + /** + Set a canonical option identifier to be used anywhere in the API. + @param {String} _name option name + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.name = function(_name) { + this._name = _name; + return this; + }; + + /** + Set a long description for option to be used anywhere in text messages. + @param {String} _title option title + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.title = Cmd.prototype.title; + + /** + Set a short key for option to be used with one hyphen from command line. + @param {String} _short + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.short = function(_short) { + this._short = _short; + return this._cmd._optsByKey['-' + _short] = this; + }; + + /** + Set a short key for option to be used with double hyphens from command line. + @param {String} _long + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.long = function(_long) { + this._long = _long; + return this._cmd._optsByKey['--' + _long] = this; + }; + + /** + Make an option boolean, i.e. option without value. + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.flag = function() { + this._flag = true; + return this; + }; + + /** + Makes an option accepts multiple values. + Otherwise, the value will be used by the latter passed. + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.arr = function() { + this._arr = true; + return this; + }; + + /** + Makes an option required. + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.req = function() { + this._req = true; + return this; + }; + + /** + Makes an option to act as a command, + i.e. program will exit just after option action. + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.only = function() { + this._only = true; + return this; + }; + + /** + Set a validation (or value) function for option. + Value from command line passes through before becoming available from API. + Using for validation and convertion simple types to any values. + @param {Function} _val validating function, + invoked in the context of option instance + and has one parameter with value from command line + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.val = function(_val) { + this._val = _val; + return this; + }; + + /** + Set a default value for option. + Default value passed through validation function as ordinary value. + @param {Object} _def + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.def = function(_def) { + this._def = _def; + return this; + }; + + /** + Make option value inputting stream. + It's add useful validation and shortcut for STDIN. + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.input = function() { + process.stdin.pause(); + return this.def(process.stdin).val(function(v) { + var s; + if (typeof v === 'string') { + if (v === '-') { + return process.stdin; + } else { + s = fs.createReadStream(v, { + encoding: 'utf8' + }); + s.pause(); + return s; + } + } else { + return v; + } + }); + }; + + /** + Make option value outputing stream. + It's add useful validation and shortcut for STDOUT. + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.output = function() { + return this.def(process.stdout).val(function(v) { + if (typeof v === 'string') { + if (v === '-') { + return process.stdout; + } else { + return fs.createWriteStream(v, { + encoding: 'utf8' + }); + } + } else { + return v; + } + }); + }; + + /** + Add action for current option command. + This action is performed if the current option + is present in parsed options (with any value). + @param {Function} act action function, + invoked in the context of command instance + and has the parameters: + - {Object} opts parsed options + - {Array} args parsed arguments + - {Object} res actions result accumulator + It can return rejected promise by Cmd.reject (in case of error) + or any other value treated as result. + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.act = function(act) { + var name, opt; + opt = this; + name = this._name; + this._cmd.act(function(opts) { + var res, + _this = this; + if (name in opts) { + res = act.apply(this, arguments); + if (opt._only) { + return Q.when(res, function(res) { + return _this.reject({ + toString: function() { + return res.toString(); + }, + exitCode: 0 + }); + }); + } else { + return res; + } + } + }); + return this; + }; + + /** + Set custom additional completion for current option. + @param {Function} completion generation function, + invoked in the context of option instance. + Accepts parameters: + - {Object} opts completion options + It can return promise or any other value treated as result. + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.comp = Cmd.prototype.comp; + + Opt.prototype._saveVal = function(opts, val) { + var _name; + if (this._val) { + val = this._val(val); + } + if (this._arr) { + (opts[_name = this._name] || (opts[_name] = [])).push(val); + } else { + opts[this._name] = val; + } + return val; + }; + + Opt.prototype._parse = function(argv, opts) { + return this._saveVal(opts, this._flag ? true : argv.shift()); + }; + + Opt.prototype._checkParsed = function(opts, args) { + return !opts.hasOwnProperty(this._name); + }; + + Opt.prototype._usage = function() { + var nameStr, res; + res = []; + nameStr = this._name.toUpperCase(); + if (this._short) { + res.push('-', Color('lgreen', this._short)); + if (!this._flag) { + res.push(' ' + nameStr); + } + res.push(', '); + } + if (this._long) { + res.push('--', Color('green', this._long)); + if (!this._flag) { + res.push('=' + nameStr); + } + } + res.push(' : ', this._title); + if (this._req) { + res.push(' ', Color('lred', '(required)')); + } + return res.join(''); + }; + + Opt.prototype._requiredText = function() { + return 'Missing required option:\n ' + this._usage(); + }; + + /** + Return rejected promise with error code. + Use in .val() for return with error. + @param {Object} reject reason + You can customize toString() method and exitCode property + of reason object. + @returns {Q.promise} rejected promise + */ + + + Opt.prototype.reject = Cmd.prototype.reject; + + /** + Finish chain for current option and return parent command instance. + @returns {COA.Cmd} parent command + */ + + + Opt.prototype.end = Cmd.prototype.end; + + /** + Apply function with arguments in context of option instance. + @param {Function} fn + @param {Array} args + @returns {COA.Opt} this instance (for chainability) + */ + + + Opt.prototype.apply = Cmd.prototype.apply; + + return Opt; + +})(); diff --git a/node_modules/coa/lib/shell.js b/node_modules/coa/lib/shell.js new file mode 100644 index 00000000..f3d49662 --- /dev/null +++ b/node_modules/coa/lib/shell.js @@ -0,0 +1,14 @@ +// Generated by CoffeeScript 1.6.3 +exports.unescape = function(w) { + w = w.charAt(0) === '"' ? w.replace(/^"|([^\\])"$/g, '$1') : w.replace(/\\ /g, ' '); + return w.replace(/\\("|'|\$|`|\\)/g, '$1'); +}; + +exports.escape = function(w) { + w = w.replace(/(["'$`\\])/g, '\\$1'); + if (w.match(/\s+/)) { + return '"' + w + '"'; + } else { + return w; + } +}; diff --git a/node_modules/coa/package.json b/node_modules/coa/package.json new file mode 100644 index 00000000..925b4859 --- /dev/null +++ b/node_modules/coa/package.json @@ -0,0 +1,44 @@ +{ + "name": "coa", + "description": "Command-Option-Argument: Yet another parser for command line options.", + "version": "1.0.4", + "homepage": "http://github.com/veged/coa", + "author": "Sergey Berezhnoy (http://github.com/veged)", + "maintainers": [ + "Sergey Berezhnoy (http://github.com/veged)", + "Sergey Belov (http://github.com/arikon)" + ], + "contributors": [ + "Sergey Belov (http://github.com/arikon)" + ], + "repository": { + "type": "git", + "url": "git://github.com/veged/coa.git" + }, + "directories": { + "lib": "./lib" + }, + "dependencies": { + "q": "^1.1.2" + }, + "devDependencies": { + "coffee-script": "~1.6.3", + "istanbul": "~0.1.40", + "mocha-istanbul": "*", + "mocha": "~1.21.4", + "chai": "~1.7.2" + }, + "scripts": { + "test": "make test", + "coverage": "make coverage" + }, + "engines": { + "node": ">= 0.8.0" + }, + "licenses": [ + { + "type": "MIT" + } + ], + "optionalDependencies": {} +} diff --git a/node_modules/coa/qq.js b/node_modules/coa/qq.js new file mode 100644 index 00000000..4aeb9844 --- /dev/null +++ b/node_modules/coa/qq.js @@ -0,0 +1,17 @@ +const run = require('./test/util').run; + +// run(cmd => cmd.arg().name('qwe').end().arg().name('zxc').end().act(function(opts, args) { console.log({opts, args}); }), ['qwe', 'zxc']) // cmd and args +// .then(res => { +// // code +// // stdout +// // stderr +// console.log(res); +// }); + +run(cmd => cmd.opt().name('version').short('v').only().flag().act((opts) => { return 'aasd'; }), ['-v']) // cmd and args + .then(res => { + // code + // stdout + // stderr + console.log(res); + }); diff --git a/node_modules/coa/src/arg.coffee b/node_modules/coa/src/arg.coffee new file mode 100644 index 00000000..da57dff0 --- /dev/null +++ b/node_modules/coa/src/arg.coffee @@ -0,0 +1,130 @@ +Color = require('./color').Color +Cmd = require('./cmd').Cmd +Opt = require('./opt').Opt + +###* +Argument + +Unnamed entity. From command line arguments passed as list of unnamed values. +@namespace +@class Presents argument +### +exports.Arg = class Arg + + ###* + @constructs + @param {COA.Cmd} cmd parent command + ### + constructor: (@_cmd) -> @_cmd._args.push @ + + ###* + Set a canonical argument identifier to be used anywhere in text messages. + @param {String} _name argument name + @returns {COA.Arg} this instance (for chainability) + ### + name: Opt::name + + ###* + Set a long description for argument to be used anywhere in text messages. + @param {String} _title argument title + @returns {COA.Arg} this instance (for chainability) + ### + title: Cmd::title + + ###* + Makes an argument accepts multiple values. + Otherwise, the value will be used by the latter passed. + @returns {COA.Arg} this instance (for chainability) + ### + arr: Opt::arr + + ###* + Makes an argument required. + @returns {COA.Arg} this instance (for chainability) + ### + req: Opt::req + + ###* + Set a validation (or value) function for argument. + Value from command line passes through before becoming available from API. + Using for validation and convertion simple types to any values. + @param {Function} _val validating function, + invoked in the context of argument instance + and has one parameter with value from command line + @returns {COA.Arg} this instance (for chainability) + ### + val: Opt::val + + ###* + Set a default value for argument. + Default value passed through validation function as ordinary value. + @param {Object} _def + @returns {COA.Arg} this instance (for chainability) + ### + def: Opt::def + + ###* + Set custom additional completion for current argument. + @param {Function} completion generation function, + invoked in the context of argument instance. + Accepts parameters: + - {Object} opts completion options + It can return promise or any other value treated as result. + @returns {COA.Arg} this instance (for chainability) + ### + comp: Cmd::comp + + ###* + Make argument value inputting stream. + It's add useful validation and shortcut for STDIN. + @returns {COA.Arg} this instance (for chainability) + ### + input: Opt::input + + ###* + Make argument value outputing stream. + It's add useful validation and shortcut for STDOUT. + @returns {COA.Arg} this instance (for chainability) + ### + output: Opt::output + + _parse: (arg, args) -> + @_saveVal(args, arg) + + _saveVal: Opt::_saveVal + + _checkParsed: (opts, args) -> not args.hasOwnProperty(@_name) + + _usage: -> + res = [] + + res.push Color('lpurple', @_name.toUpperCase()), ' : ', @_title + if @_req then res.push ' ', Color('lred', '(required)') + + res.join '' + + _requiredText: -> 'Missing required argument:\n ' + @_usage() + + ###* + Return rejected promise with error code. + Use in .val() for return with error. + @param {Object} reject reason + You can customize toString() method and exitCode property + of reason object. + @returns {Q.promise} rejected promise + ### + reject: Cmd::reject + + ###* + Finish chain for current option and return parent command instance. + @returns {COA.Cmd} parent command + ### + end: Cmd::end + + ###* + Apply function with arguments in context of arg instance. + @param {Function} fn + @param {Array} args + @returns {COA.Arg} this instance (for chainability) + ### + apply: Cmd::apply diff --git a/node_modules/coa/src/cmd.coffee b/node_modules/coa/src/cmd.coffee new file mode 100644 index 00000000..bde16248 --- /dev/null +++ b/node_modules/coa/src/cmd.coffee @@ -0,0 +1,456 @@ +UTIL = require 'util' +PATH = require 'path' +Color = require('./color').Color +Q = require('q') + +#inspect = require('eyes').inspector { maxLength: 99999, stream: process.stderr } + +###* +Command + +Top level entity. Commands may have options and arguments. +@namespace +@class Presents command +### +exports.Cmd = class Cmd + + ###* + @constructs + @param {COA.Cmd} [cmd] parent command + ### + constructor: (cmd) -> + if this not instanceof Cmd + return new Cmd cmd + + @_parent cmd + + @_cmds = [] + @_cmdsByName = {} + + @_opts = [] + @_optsByKey = {} + + @_args = [] + + @_ext = false + + @get: (propertyName, func) -> + Object.defineProperty @::, propertyName, + configurable: true + enumerable: true + get: func + + ###* + Returns object containing all its subcommands as methods + to use from other programs. + @returns {Object} + ### + @get 'api', () -> + if not @_api + @_api = => @invoke.apply @, arguments + for c of @_cmdsByName + do (c) => + @_api[c] = @_cmdsByName[c].api + @_api + + _parent: (cmd) -> + @_cmd = cmd or this + if cmd + cmd._cmds.push @ + if @_name then @_cmd._cmdsByName[@_name] = @ + @ + + ###* + Set a canonical command identifier to be used anywhere in the API. + @param {String} _name command name + @returns {COA.Cmd} this instance (for chainability) + ### + name: (@_name) -> + if @_cmd isnt @ then @_cmd._cmdsByName[_name] = @ + @ + + ###* + Set a long description for command to be used anywhere in text messages. + @param {String} _title command title + @returns {COA.Cmd} this instance (for chainability) + ### + title: (@_title) -> @ + + ###* + Create new or add existing subcommand for current command. + @param {COA.Cmd} [cmd] existing command instance + @returns {COA.Cmd} new subcommand instance + ### + cmd: (cmd) -> + if cmd then cmd._parent @ + else new Cmd @ + + ###* + Create option for current command. + @returns {COA.Opt} new option instance + ### + opt: -> new (require('./opt').Opt) @ + + ###* + Create argument for current command. + @returns {COA.Opt} new argument instance + ### + arg: -> new (require('./arg').Arg) @ + + ###* + Add (or set) action for current command. + @param {Function} act action function, + invoked in the context of command instance + and has the parameters: + - {Object} opts parsed options + - {Array} args parsed arguments + - {Object} res actions result accumulator + It can return rejected promise by Cmd.reject (in case of error) + or any other value treated as result. + @param {Boolean} [force=false] flag for set action instead add to existings + @returns {COA.Cmd} this instance (for chainability) + ### + act: (act, force) -> + return @ unless act + + if not force and @_act + @_act.push act + else + @_act = [act] + + @ + + ###* + Set custom additional completion for current command. + @param {Function} completion generation function, + invoked in the context of command instance. + Accepts parameters: + - {Object} opts completion options + It can return promise or any other value treated as result. + @returns {COA.Cmd} this instance (for chainability) + ### + comp: (@_comp) -> @ + + ###* + Apply function with arguments in context of command instance. + @param {Function} fn + @param {Array} args + @returns {COA.Cmd} this instance (for chainability) + ### + apply: (fn, args...) -> + fn.apply this, args + @ + + ###* + Make command "helpful", i.e. add -h --help flags for print usage. + @returns {COA.Cmd} this instance (for chainability) + ### + helpful: -> + @opt() + .name('help').title('Help') + .short('h').long('help') + .flag() + .only() + .act -> + return @usage() + .end() + + ###* + Adds shell completion to command, adds "completion" subcommand, + that makes all the magic. + Must be called only on root command. + @returns {COA.Cmd} this instance (for chainability) + ### + completable: -> + @cmd() + .name('completion') + .apply(require './completion') + .end() + + ###* + Allow command to be extendable by external node.js modules. + @param {String} [pattern] Pattern of node.js module to find subcommands at. + @returns {COA.Cmd} this instance (for chainability) + ### + extendable: (pattern) -> + @_ext = pattern or true + @ + + _exit: (msg, code) -> + process.once 'exit', -> + if msg then console.error msg + process.exit code or 0 + + ###* + Build full usage text for current command instance. + @returns {String} usage text + ### + usage: -> + res = [] + + if @_title then res.push @_fullTitle() + + res.push('', 'Usage:') + + if @_cmds.length then res.push(['', '', + Color('lred', @_fullName()), + Color('lblue', 'COMMAND'), + Color('lgreen', '[OPTIONS]'), + Color('lpurple', '[ARGS]')].join ' ') + + if @_opts.length + @_args.length then res.push(['', '', + Color('lred', @_fullName()), + Color('lgreen', '[OPTIONS]'), + Color('lpurple', '[ARGS]')].join ' ') + + res.push( + @_usages(@_cmds, 'Commands'), + @_usages(@_opts, 'Options'), + @_usages(@_args, 'Arguments')) + + res.join '\n' + + _usage: -> + Color('lblue', @_name) + ' : ' + @_title + + _usages: (os, title) -> + unless os.length then return + res = ['', title + ':'] + for o in os + res.push ' ' + o._usage() + res.join '\n' + + _fullTitle: -> + (if @_cmd is this then '' else @_cmd._fullTitle() + '\n') + @_title + + _fullName: -> + (if this._cmd is this then '' else @_cmd._fullName() + ' ') + PATH.basename(@_name) + + _ejectOpt: (opts, opt) -> + if (pos = opts.indexOf(opt)) >= 0 + if opts[pos]._arr + opts[pos] + else + opts.splice(pos, 1)[0] + + _checkRequired: (opts, args) -> + if not (@_opts.filter (o) -> o._only and o._name of opts).length + all = @_opts.concat @_args + while i = all.shift() + if i._req and i._checkParsed opts, args + return @reject i._requiredText() + + _parseCmd: (argv, unparsed = []) -> + argv = argv.concat() + optSeen = false + while i = argv.shift() + if not i.indexOf '-' + optSeen = true + if not optSeen and /^\w[\w-_]*$/.test(i) + cmd = @_cmdsByName[i] + + if not cmd and @_ext + # construct package name to require + if typeof @_ext is 'string' + if ~@_ext.indexOf('%s') + # use formatted string + pkg = UTIL.format(@_ext, i) + else + # just append subcommand name to the prefix + pkg = @_ext + i + else if @_ext is true + # use default scheme: -- and so on + pkg = i + c = @ + loop + pkg = c._name + '-' + pkg + if c._cmd is c then break + c = c._cmd + + try + cmdDesc = require(pkg) + catch e + + if cmdDesc + if typeof cmdDesc == 'function' + # set create subcommand, set its name and apply imported function + @cmd() + .name(i) + .apply(cmdDesc) + .end() + else if typeof cmdDesc == 'object' + # register subcommand + @cmd(cmdDesc) + # set command name + cmdDesc.name(i) + else + throw new Error 'Error: Unsupported command declaration type, ' + + 'should be function or COA.Cmd() object' + cmd = @_cmdsByName[i] + if cmd + return cmd._parseCmd argv, unparsed + + unparsed.push i + + { cmd: @, argv: unparsed } + + _parseOptsAndArgs: (argv) -> + opts = {} + args = {} + + nonParsedOpts = @_opts.concat() + nonParsedArgs = @_args.concat() + + while i = argv.shift() + # opt + if i isnt '--' and not i.indexOf '-' + + if m = i.match /^(--\w[\w-_]*)=(.*)$/ + i = m[1] + + # suppress 'unknown argument' error for flag options with values + if not @_optsByKey[i]._flag + argv.unshift m[2] + + if opt = @_ejectOpt nonParsedOpts, @_optsByKey[i] + if Q.isRejected(res = opt._parse argv, opts) + return res + else + return @reject "Unknown option: #{ i }" + + # arg + else + if i is '--' + i = argv.splice(0) + + i = if Array.isArray(i) then i else [i] + + while a = i.shift() + if arg = nonParsedArgs.shift() + if arg._arr then nonParsedArgs.unshift arg + if Q.isRejected(res = arg._parse a, args) + return res + else + return @reject "Unknown argument: #{ a }" + + # set defaults + { + opts: @_setDefaults(opts, nonParsedOpts), + args: @_setDefaults(args, nonParsedArgs) + } + + _setDefaults: (params, desc) -> + for i in desc + if i._name not of params and '_def' of i + i._saveVal params, i._def + params + + _processParams: (params, desc) -> + notExists = [] + for i in desc + n = i._name + if n not of params + notExists.push i + continue + + vals = params[n] + delete params[n] + if not Array.isArray vals + vals = [vals] + + for v in vals + if Q.isRejected(res = i._saveVal(params, v)) + return res + + # set defaults + @_setDefaults params, notExists + + _parseArr: (argv) -> + Q.when @_parseCmd(argv), (p) -> + Q.when p.cmd._parseOptsAndArgs(p.argv), (r) -> + { cmd: p.cmd, opts: r.opts, args: r.args } + + _do: (input) -> + Q.when input, (input) => + cmd = input.cmd + [@_checkRequired].concat(cmd._act or []).reduce( + (res, act) -> + Q.when res, (res) -> + act.call( + cmd + input.opts + input.args + res) + undefined + ) + + ###* + Parse arguments from simple format like NodeJS process.argv + and run ahead current program, i.e. call process.exit when all actions done. + @param {Array} argv + @returns {COA.Cmd} this instance (for chainability) + ### + run: (argv = process.argv.slice(2)) -> + cb = (code) => (res) => + if res + @_exit res.stack ? res.toString(), res.exitCode ? code + else + @_exit() + Q.when(@do(argv), cb(0), cb(1)).done() + @ + + ###* + Convenient function to run command from tests. + @param {Array} argv + @returns {Q.Promise} + ### + do: (argv) -> + @_do(@_parseArr argv || []) + + ###* + Invoke specified (or current) command using provided + options and arguments. + @param {String|Array} cmds subcommand to invoke (optional) + @param {Object} opts command options (optional) + @param {Object} args command arguments (optional) + @returns {Q.Promise} + ### + invoke: (cmds = [], opts = {}, args = {}) -> + if typeof cmds == 'string' + cmds = cmds.split(' ') + + if arguments.length < 3 + if not Array.isArray cmds + args = opts + opts = cmds + cmds = [] + + Q.when @_parseCmd(cmds), (p) => + if p.argv.length + return @reject "Unknown command: " + cmds.join ' ' + + Q.all([@_processParams(opts, @_opts), @_processParams(args, @_args)]) + .spread (opts, args) => + @_do({ cmd: p.cmd, opts: opts, args: args }) + # catch fails from .only() options + .fail (res) => + if res and res.exitCode is 0 + res.toString() + else + @reject(res) + + ###* + Return reject of actions results promise with error code. + Use in .act() for return with error. + @param {Object} reject reason + You can customize toString() method and exitCode property + of reason object. + @returns {Q.promise} rejected promise + ### + reject: (reason) -> Q.reject(reason) + + ###* + Finish chain for current subcommand and return parent command instance. + @returns {COA.Cmd} parent command + ### + end: -> @_cmd diff --git a/node_modules/coa/src/color.coffee b/node_modules/coa/src/color.coffee new file mode 100644 index 00000000..f07a3a57 --- /dev/null +++ b/node_modules/coa/src/color.coffee @@ -0,0 +1,25 @@ +colors = + black: '30' + dgray: '1;30' + red: '31' + lred: '1;31' + green: '32' + lgreen: '1;32' + brown: '33' + yellow: '1;33' + blue: '34' + lblue: '1;34' + purple: '35' + lpurple: '1;35' + cyan: '36' + lcyan: '1;36' + lgray: '37' + white: '1;37' + +exports.Color = (c, str) -> + # Use \x1B instead of \033 because of CoffeeScript 1.3.x compilation error + [ + '\x1B[', colors[c], 'm' + str + '\x1B[m' + ].join '' diff --git a/node_modules/coa/src/completion.coffee b/node_modules/coa/src/completion.coffee new file mode 100644 index 00000000..2c1e358d --- /dev/null +++ b/node_modules/coa/src/completion.coffee @@ -0,0 +1,156 @@ +###* +Most of the code adopted from the npm package shell completion code. +See https://github.com/isaacs/npm/blob/master/lib/completion.js +### + +Q = require 'q' +escape = require('./shell').escape +unescape = require('./shell').unescape + +module.exports = -> + @title('Shell completion') + .helpful() + .arg() + .name('raw') + .title('Completion words') + .arr() + .end() + .act (opts, args) -> + if process.platform == 'win32' + e = new Error 'shell completion not supported on windows' + e.code = 'ENOTSUP' + e.errno = require('constants').ENOTSUP + return @reject(e) + + # if the COMP_* isn't in the env, then just dump the script + if !process.env.COMP_CWORD? or !process.env.COMP_LINE? or !process.env.COMP_POINT? + return dumpScript(@_cmd._name) + + console.error 'COMP_LINE: %s', process.env.COMP_LINE + console.error 'COMP_CWORD: %s', process.env.COMP_CWORD + console.error 'COMP_POINT: %s', process.env.COMP_POINT + console.error 'args: %j', args.raw + + # completion opts + opts = getOpts args.raw + + # cmd + { cmd, argv } = @_cmd._parseCmd opts.partialWords + Q.when complete(cmd, opts), (compls) -> + console.error 'filtered: %j', compls + console.log compls.map(escape).join('\n') + + +dumpScript = (name) -> + fs = require 'fs' + path = require 'path' + defer = Q.defer() + + fs.readFile path.resolve(__dirname, 'completion.sh'), 'utf8', (err, d) -> + if err then return defer.reject err + d = d.replace(/{{cmd}}/g, path.basename name).replace(/^\#\!.*?\n/, '') + + onError = (err) -> + # Darwin is a real dick sometimes. + # + # This is necessary because the "source" or "." program in + # bash on OS X closes its file argument before reading + # from it, meaning that you get exactly 1 write, which will + # work most of the time, and will always raise an EPIPE. + # + # Really, one should not be tossing away EPIPE errors, or any + # errors, so casually. But, without this, `. <(cmd completion)` + # can never ever work on OS X. + if err.errno == require('constants').EPIPE + process.stdout.removeListener 'error', onError + defer.resolve() + else + defer.reject(err) + + process.stdout.on 'error', onError + process.stdout.write d, -> defer.resolve() + + defer.promise + + +getOpts = (argv) -> + # get the partial line and partial word, if the point isn't at the end + # ie, tabbing at: cmd foo b|ar + line = process.env.COMP_LINE + w = +process.env.COMP_CWORD + point = +process.env.COMP_POINT + words = argv.map unescape + word = words[w] + partialLine = line.substr 0, point + partialWords = words.slice 0, w + + # figure out where in that last word the point is + partialWord = argv[w] or '' + i = partialWord.length + while partialWord.substr(0, i) isnt partialLine.substr(-1 * i) and i > 0 + i-- + partialWord = unescape partialWord.substr 0, i + if partialWord then partialWords.push partialWord + + { + line: line + w: w + point: point + words: words + word: word + partialLine: partialLine + partialWords: partialWords + partialWord: partialWord + } + + +complete = (cmd, opts) -> + compls = [] + + # complete on cmds + if opts.partialWord.indexOf('-') + compls = Object.keys(cmd._cmdsByName) + # Complete on required opts without '-' in last partial word + # (if required not already specified) + # + # Commented out because of uselessness: + # -b, --block suggest results in '-' on cmd line; + # next completion suggest all options, because of '-' + #.concat Object.keys(cmd._optsByKey).filter (v) -> cmd._optsByKey[v]._req + else + # complete on opt values: --opt=| case + if m = opts.partialWord.match /^(--\w[\w-_]*)=(.*)$/ + optWord = m[1] + optPrefix = optWord + '=' + else + # complete on opts + # don't complete on opts in case of --opt=val completion + # TODO: don't complete on opts in case of unknown arg after commands + # TODO: complete only on opts with arr() or not already used + # TODO: complete only on full opts? + compls = Object.keys cmd._optsByKey + + # complete on opt values: next arg case + if not (o = opts.partialWords[opts.w - 1]).indexOf '-' + optWord = o + + # complete on opt values: completion + if optWord and opt = cmd._optsByKey[optWord] + if not opt._flag and opt._comp + compls = Q.join compls, Q.when opt._comp(opts), (c, o) -> + c.concat o.map (v) -> (optPrefix or '') + v + + # TODO: complete on args values (context aware, custom completion?) + + # custom completion on cmds + if cmd._comp + compls = Q.join compls, Q.when(cmd._comp(opts)), (c, o) -> + c.concat o + + # TODO: context aware custom completion on cmds, opts and args + # (can depend on already entered values, especially options) + + Q.when compls, (compls) -> + console.error 'partialWord: %s', opts.partialWord + console.error 'compls: %j', compls + compls.filter (c) -> c.indexOf(opts.partialWord) is 0 diff --git a/node_modules/coa/src/index.coffee b/node_modules/coa/src/index.coffee new file mode 100644 index 00000000..ae594be3 --- /dev/null +++ b/node_modules/coa/src/index.coffee @@ -0,0 +1,5 @@ +exports.Cmd = require('./cmd').Cmd +exports.Opt = require('./cmd').Opt +exports.Arg = require('./cmd').Arg +exports.shell = require('./shell') +exports.require = require; diff --git a/node_modules/coa/src/opt.coffee b/node_modules/coa/src/opt.coffee new file mode 100644 index 00000000..466383df --- /dev/null +++ b/node_modules/coa/src/opt.coffee @@ -0,0 +1,243 @@ +fs = require 'fs' +Q = require 'q' +Color = require('./color').Color +Cmd = require('./cmd').Cmd + +###* +Option + +Named entity. Options may have short and long keys for use from command line. +@namespace +@class Presents option +### +exports.Opt = class Opt + + ###* + @constructs + @param {COA.Cmd} cmd parent command + ### + constructor: (@_cmd) -> @_cmd._opts.push @ + + ###* + Set a canonical option identifier to be used anywhere in the API. + @param {String} _name option name + @returns {COA.Opt} this instance (for chainability) + ### + name: (@_name) -> @ + + ###* + Set a long description for option to be used anywhere in text messages. + @param {String} _title option title + @returns {COA.Opt} this instance (for chainability) + ### + title: Cmd::title + + ###* + Set a short key for option to be used with one hyphen from command line. + @param {String} _short + @returns {COA.Opt} this instance (for chainability) + ### + short: (@_short) -> @_cmd._optsByKey['-' + _short] = @ + + ###* + Set a short key for option to be used with double hyphens from command line. + @param {String} _long + @returns {COA.Opt} this instance (for chainability) + ### + long: (@_long) -> @_cmd._optsByKey['--' + _long] = @ + + ###* + Make an option boolean, i.e. option without value. + @returns {COA.Opt} this instance (for chainability) + ### + flag: () -> + @_flag = true + @ + + ###* + Makes an option accepts multiple values. + Otherwise, the value will be used by the latter passed. + @returns {COA.Opt} this instance (for chainability) + ### + arr: -> + @_arr = true + @ + + ###* + Makes an option required. + @returns {COA.Opt} this instance (for chainability) + ### + req: -> + @_req = true + @ + + ###* + Makes an option to act as a command, + i.e. program will exit just after option action. + @returns {COA.Opt} this instance (for chainability) + ### + only: -> + @_only = true + @ + + ###* + Set a validation (or value) function for option. + Value from command line passes through before becoming available from API. + Using for validation and convertion simple types to any values. + @param {Function} _val validating function, + invoked in the context of option instance + and has one parameter with value from command line + @returns {COA.Opt} this instance (for chainability) + ### + val: (@_val) -> @ + + ###* + Set a default value for option. + Default value passed through validation function as ordinary value. + @param {Object} _def + @returns {COA.Opt} this instance (for chainability) + ### + def: (@_def) -> @ + + ###* + Make option value inputting stream. + It's add useful validation and shortcut for STDIN. + @returns {COA.Opt} this instance (for chainability) + ### + input: -> + # XXX: hack to workaround a bug in node 0.6.x, + # see https://github.com/joyent/node/issues/2130 + process.stdin.pause(); + + @ + .def(process.stdin) + .val (v) -> + if typeof v is 'string' + if v is '-' + process.stdin + else + s = fs.createReadStream v, { encoding: 'utf8' } + s.pause() + s + else v + + ###* + Make option value outputing stream. + It's add useful validation and shortcut for STDOUT. + @returns {COA.Opt} this instance (for chainability) + ### + output: -> + @ + .def(process.stdout) + .val (v) -> + if typeof v is 'string' + if v is '-' + process.stdout + else + fs.createWriteStream v, { encoding: 'utf8' } + else v + + ###* + Add action for current option command. + This action is performed if the current option + is present in parsed options (with any value). + @param {Function} act action function, + invoked in the context of command instance + and has the parameters: + - {Object} opts parsed options + - {Array} args parsed arguments + - {Object} res actions result accumulator + It can return rejected promise by Cmd.reject (in case of error) + or any other value treated as result. + @returns {COA.Opt} this instance (for chainability) + ### + act: (act) -> + opt = @ + name = @_name + @_cmd.act (opts) -> + if name of opts + res = act.apply @, arguments + if opt._only + Q.when res, (res) => + @reject { + toString: -> res.toString() + exitCode: 0 + } + else + res + @ + + ###* + Set custom additional completion for current option. + @param {Function} completion generation function, + invoked in the context of option instance. + Accepts parameters: + - {Object} opts completion options + It can return promise or any other value treated as result. + @returns {COA.Opt} this instance (for chainability) + ### + comp: Cmd::comp + + _saveVal: (opts, val) -> + if @_val then val = @_val val + if @_arr + (opts[@_name] or= []).push val + else + opts[@_name] = val + val + + _parse: (argv, opts) -> + @_saveVal( + opts, + if @_flag + true + else + argv.shift() + ) + + _checkParsed: (opts, args) -> not opts.hasOwnProperty @_name + + _usage: -> + res = [] + nameStr = @_name.toUpperCase() + + if @_short + res.push '-', Color 'lgreen', @_short + unless @_flag then res.push ' ' + nameStr + res.push ', ' + + if @_long + res.push '--', Color 'green', @_long + unless @_flag then res.push '=' + nameStr + + res.push ' : ', @_title + + if @_req then res.push ' ', Color('lred', '(required)') + + res.join '' + + _requiredText: -> 'Missing required option:\n ' + @_usage() + + ###* + Return rejected promise with error code. + Use in .val() for return with error. + @param {Object} reject reason + You can customize toString() method and exitCode property + of reason object. + @returns {Q.promise} rejected promise + ### + reject: Cmd::reject + + ###* + Finish chain for current option and return parent command instance. + @returns {COA.Cmd} parent command + ### + end: Cmd::end + + ###* + Apply function with arguments in context of option instance. + @param {Function} fn + @param {Array} args + @returns {COA.Opt} this instance (for chainability) + ### + apply: Cmd::apply diff --git a/node_modules/coa/src/shell.coffee b/node_modules/coa/src/shell.coffee new file mode 100644 index 00000000..efad108d --- /dev/null +++ b/node_modules/coa/src/shell.coffee @@ -0,0 +1,10 @@ +exports.unescape = (w) -> + w = if w.charAt(0) is '"' + w.replace(/^"|([^\\])"$/g, '$1') + else + w.replace(/\\ /g, ' ') + w.replace(/\\("|'|\$|`|\\)/g, '$1') + +exports.escape = (w) -> + w = w.replace(/(["'$`\\])/g,'\\$1') + if w.match(/\s+/) then '"' + w + '"' else w diff --git a/node_modules/coa/test/coa.js b/node_modules/coa/test/coa.js new file mode 100644 index 00000000..4277321a --- /dev/null +++ b/node_modules/coa/test/coa.js @@ -0,0 +1,496 @@ +var assert = require('chai').assert, + COA = require('..'); + +/** + * Mocha BDD interface. + */ +/** @name describe @function */ +/** @name it @function */ +/** @name before @function */ +/** @name after @function */ +/** @name beforeEach @function */ +/** @name afterEach @function */ + +describe('Opt', function() { + + describe('Unknown option', function() { + + var cmd = COA.Cmd(); + + it('should fail', function() { + return cmd.do(['-a']) + .then(assert.fail, emptyFn); + }); + + }); + + describe('Short options', function() { + + var cmd = COA.Cmd() + .opt() + .name('a') + .short('a') + .end() + .opt() + .name('b') + .short('b') + .end() + .act(function(opts) { + return opts; + }); + + it('should return passed values', function() { + return cmd.do(['-a', 'a', '-b', 'b']) + .then(function(res) { + assert.deepEqual(res, { a: 'a', b: 'b' }); + }); + }); + + }); + + describe('Long options', function() { + + var cmd = COA.Cmd() + .opt() + .name('long1') + .long('long1') + .end() + .opt() + .name('long2') + .long('long2') + .end() + .act(function(opts) { + return opts; + }); + + it('should return passed values', function() { + return cmd.do(['--long1', 'long value', '--long2=another long value']) + .then(function(res) { + assert.deepEqual(res, { long1: 'long value', long2: 'another long value' }); + }); + }); + + }); + + describe('Array option', function() { + + var cmd = COA.Cmd() + .opt() + .name('a') + .short('a') + .arr() + .end() + .act(function(opts) { + return opts; + }); + + it('should return array of passed values', function() { + return cmd.do(['-a', '1', '-a', '2']) + .then(function(res) { + assert.deepEqual(res, { a: ['1', '2'] }); + }); + }); + + }); + + describe('Required option', function() { + + var cmd = COA.Cmd() + .opt() + .name('a') + .short('a') + .req() + .end() + .act(function(opts) { + return opts; + }); + + it('should fail if not specified', function() { + return cmd.do() + .then(assert.fail, emptyFn); + }); + + it('should return passed value if specified', function() { + return cmd.do(['-a', 'test']) + .then(function(opts) { + assert.equal(opts.a, 'test'); + }); + }); + + }); + + describe('Option with default value', function() { + + var cmd = COA.Cmd() + .opt() + .name('a') + .short('a') + .def('aaa') + .end() + .act(function(opts) { + return opts; + }); + + it('should return default value if not specified', function() { + return cmd.do() + .then(function(opts) { + assert.equal(opts.a, 'aaa'); + }); + }); + + it('should return passed value if specified', function() { + return cmd.do(['-a', 'test']) + .then(function(opts) { + assert.equal(opts.a, 'test'); + }); + }); + + }); + + describe('Validated / transformed option', function() { + + var cmd = COA.Cmd() + .opt() + .name('a') + .short('a') + .val(function(v) { + if (v === 'invalid') return this.reject('fail'); + return { value: v }; + }) + .end() + .act(function(opts) { + return opts; + }); + + it('should fail if custom checks suppose to do so', function() { + return cmd.do(['-a', 'invalid']) + .then(assert.fail, emptyFn); + }); + + it('should return transformed value', function() { + return cmd.do(['-a', 'test']) + .then(function(opts) { + assert.deepEqual(opts.a, { value: 'test' }); + }); + }); + + }); + + describe('Only option (--version case)', function() { + + var ver = require('../package.json').version, + cmd = COA.Cmd() + .opt() + .name('version') + .long('version') + .flag() + .only() + .act(function() { + return ver; + }) + .end() + .opt() + .name('req') + .short('r') + .req() + .end(); + + it('should process the only() option', function() { + return cmd.do(['--version']) + .then(assert.fail, function(res) { + assert.equal(res, ver); + }); + }); + + }); + + it('input()'); + it('output()'); + +}); + +describe('Arg', function() { + + describe('Unknown arg', function() { + + var cmd = COA.Cmd(); + + it('should fail', function() { + return cmd.do(['test']) + .then(assert.fail, emptyFn); + }); + + }); + + describe('Unknown arg after known', function() { + + var cmd = COA.Cmd() + .arg() + .name('a') + .end(); + + it('should fail', function() { + return cmd.do(['test', 'unknown']) + .then(assert.fail, emptyFn); + }); + + }); + + describe('Array arg', function() { + + var cmd = COA.Cmd() + .arg() + .name('a') + .arr() + .end() + .act(function(opts, args) { + return args; + }); + + it('should return array of passed values', function() { + return cmd.do(['value 1', 'value 2']) + .then(function(args) { + assert.deepEqual(args, { a: ['value 1', 'value 2'] }); + }); + }); + + }); + + describe('Required arg', function() { + + var cmd = COA.Cmd() + .arg() + .name('a') + .req() + .end() + .act(function(opts, args) { + return args; + }); + + it('should fail if not specified', function() { + return cmd.do() + .then(assert.fail, emptyFn); + }); + + it('should return passed value if specified', function() { + return cmd.do(['value']) + .then(function(args) { + assert.equal(args.a, 'value'); + }); + }); + + }); + + describe('Args after options', function() { + + var cmd = COA.Cmd() + .opt() + .name('opt') + .long('opt') + .end() + .arg() + .name('arg1') + .end() + .arg() + .name('arg2') + .arr() + .end() + .act(function(opts, args) { + return { opts: opts, args: args }; + }); + + it('should return passed values', function() { + return cmd.do(['--opt', 'value', 'value', 'value 1', 'value 2']) + .then(function(o) { + assert.deepEqual(o, { + opts: { opt: 'value' }, + args: { + arg1: 'value', + arg2: ['value 1', 'value 2'] + } + }); + }); + }); + + }); + + describe('Raw args', function() { + + var cmd = COA.Cmd() + .arg() + .name('raw') + .arr() + .end() + .act(function(opts, args) { + return args; + }); + + it('should return passed arg values', function() { + return cmd.do(['--', 'raw', 'arg', 'values']) + .then(function(args) { + assert.deepEqual(args, { raw: ['raw', 'arg', 'values'] }); + }); + }); + + }); + +}); + +describe('Cmd', function() { + + var doTest = function(o) { + assert.deepEqual(o, { + opts: { opt: 'value' }, + args: { + arg1: 'value', + arg2: ['value 1', 'value 2'] + } + }); + }, + + invokeOpts = { opt: 'value' }, + invokeArgs = { + arg1: 'value', + arg2: ['value 1', 'value 2'] + }; + + describe('Subcommand', function() { + + var cmd = COA.Cmd() + .cmd() + .name('command') + .opt() + .name('opt') + .long('opt') + .end() + .arg() + .name('arg1') + .end() + .arg() + .name('arg2') + .arr() + .end() + .act(function(opts, args) { + return { opts: opts, args: args }; + }) + .end(); + + describe('when specified on command line', function() { + + it('should be invoked and accept passed opts and args', function() { + return cmd.do(['command', '--opt', 'value', 'value', 'value 1', 'value 2']) + .then(doTest); + }); + + }); + + describe('when invoked using api', function() { + + it('should be invoked and accept passed opts and args', function() { + return cmd.api.command(invokeOpts, invokeArgs) + .then(doTest); + }); + + }); + + describe('when invoked using invoke()', function() { + + it('should be invoked and accept passed opts and args', function() { + return cmd.invoke('command', invokeOpts, invokeArgs) + .then(doTest); + }); + + }); + + describe('when unexisting command invoked using invoke()', function() { + + it('should fail', function() { + return cmd.invoke('unexistent') + .then(assert.fail, emptyFn); + }); + + }); + + }); + + describe('External subcommand', function() { + + describe('default scheme: cmd.extendable()', function() { + + describe('when described as a function', function() { + var cmd = COA.Cmd() + .name('coa') + .extendable(); + + it('should be invoked and accept passed opts and args', function() { + return cmd.do(['test', '--opt', 'value', 'value', 'value 1', 'value 2']) + .then(doTest); + }); + }); + + describe('when described as an COA.Cmd() object', function() { + var cmd = COA.Cmd() + .name('coa') + .extendable(); + + it('should be invoked and accept passed opts and args', function() { + return cmd.do(['test-obj', '--opt', 'value', 'value', 'value 1', 'value 2']) + .then(doTest); + }); + }); + + describe('2nd level subcommand', function() { + var cmd = COA.Cmd() + .name('coa') + .cmd() + .name('test') + .extendable() + .end(); + + it('should be invoked and accept passed opts and args', function() { + return cmd.do(['test', 'obj', '--opt', 'value', 'value', 'value 1', 'value 2']) + .then(doTest); + }); + }); + + }); + + describe("common prefix: cmd.extendable('coa-')", function() { + + describe('when described as a function', function() { + var cmd = COA.Cmd() + .name('coa') + .extendable('coa-'); + + it('should be invoked and accept passed opts and args', function() { + return cmd.do(['test', '--opt', 'value', 'value', 'value 1', 'value 2']) + .then(doTest); + }); + }); + + }); + + describe("format string: cmd.extendable('coa-%s')", function() { + + describe('when described as a function', function() { + var cmd = COA.Cmd() + .name('coa') + .extendable('coa-%s'); + + it('should be invoked and accept passed opts and args', function() { + return cmd.do(['test', '--opt', 'value', 'value', 'value 1', 'value 2']) + .then(doTest); + }); + }); + + }); + + }); + + it('helpful(), name(), title()'); + +}); + +function emptyFn() { + // empty function +} diff --git a/node_modules/coa/test/mocha.opts b/node_modules/coa/test/mocha.opts new file mode 100644 index 00000000..78e17754 --- /dev/null +++ b/node_modules/coa/test/mocha.opts @@ -0,0 +1,2 @@ +--reporter spec +--timeout 20 diff --git a/node_modules/coa/test/shell-test.js b/node_modules/coa/test/shell-test.js new file mode 100644 index 00000000..7291a53d --- /dev/null +++ b/node_modules/coa/test/shell-test.js @@ -0,0 +1,60 @@ +var assert = require('chai').assert, + shell = require('..').shell; + +/** + * Mocha BDD interface. + */ +/** @name describe @function */ +/** @name it @function */ +/** @name before @function */ +/** @name after @function */ +/** @name beforeEach @function */ +/** @name afterEach @function */ + +describe('shell', function() { + + describe('escape()', function() { + + var escape = shell.escape; + + it('Should wrap values with spaces in double quotes', function() { + assert.equal(escape('asd abc'), '"asd abc"'); + }); + + it('Should escape double quote "', function() { + assert.equal(escape('"asd'), '\\"asd'); + }); + + it("Should escape single quote '", function() { + assert.equal(escape("'asd"), "\\'asd"); + }); + + it('Should escape backslash \\', function() { + assert.equal(escape('\\asd'), '\\\\asd'); + }); + + it('Should escape dollar $', function() { + assert.equal(escape('$asd'), '\\$asd'); + }); + + it('Should escape backtick `', function() { + assert.equal(escape('`asd'), '\\`asd'); + }); + + }); + + describe('unescape()', function() { + + var unescape = shell.unescape; + + it('Should strip double quotes at the both ends', function() { + assert.equal(unescape('"asd"'), 'asd'); + }); + + it('Should not strip escaped double quotes at the both ends', function() { + assert.equal(unescape('\\"asd\\"'), '"asd"'); + }); + + }); + +}); diff --git a/node_modules/coa/tests/api-h.js b/node_modules/coa/tests/api-h.js new file mode 100644 index 00000000..c343fa06 --- /dev/null +++ b/node_modules/coa/tests/api-h.js @@ -0,0 +1,9 @@ +require('..').Cmd() + .name('bla') + .title('Bla bla bla') + .helpful() + .invoke({ help: true }) + .then(function(res) { + console.log(res); + }) + .done(); // Q.done() diff --git a/node_modules/coa/tests/h.js b/node_modules/coa/tests/h.js new file mode 100644 index 00000000..b8e2c768 --- /dev/null +++ b/node_modules/coa/tests/h.js @@ -0,0 +1,6 @@ +var argv = process.argv.slice(2); +require('..').Cmd() + .name('bla') + .title('Bla bla bla') + .helpful() + .run(argv.length? argv : ['-h']); -- cgit v1.2.3