ÿØÿà JFIF    ÿÛ „  ( %"1!%)+...383,7(-.+  -+++--++++---+-+-----+---------------+---+-++7-----ÿÀ  ß â" ÿÄ     ÿÄ H    !1AQaq"‘¡2B±ÁÑð#R“Ò Tbr‚²á3csƒ’ÂñDS¢³$CÿÄ   ÿÄ %  !1AQa"23‘ÿÚ   ? ôÿ ¨pŸªáÿ —åYõõ\?àÒü©ŠÄï¨pŸªáÿ —åYõõ\?àÓü©ŠÄá 0Ÿªáÿ Ÿå[úƒ ú®ði~TÁbqÐ8OÕpÿ ƒOò¤Oè`–RÂáœá™êi€ßÉ< FtŸI“öÌ8úDf´°å}“¾œ6  öFá°y¥jñÇh†ˆ¢ã/ÃÐ:ªcÈ "Y¡ðÑl>ÿ ”ÏËte:qž\oäŠe÷󲍷˜HT4&ÿ ÓÐü6ö®¿øþßèô Ÿ•7Ñi’•j|“ñì>b…þS?*Óôÿ ÓÐü*h¥£ír¶ü UãS炟[AÐaè[ûª•õ&õj?†Éö+EzP—WeÒírJFt ‘BŒ†Ï‡%#tE Øz ¥OÛ«!1›üä±Í™%ºÍãö]°î(–:@<‹ŒÊö×òÆt¦ãº+‡¦%ÌÁ²h´OƒJŒtMÜ>ÀÜÊw3Y´•牋4ǍýʏTì>œú=Íwhyë,¾Ôò×õ¿ßÊa»«þˆѪQ|%6ž™A õ%:øj<>É—ÿ Å_ˆCbõ¥š±ý¯Ýƒï…¶|RëócÍf溪“t.СøTÿ *Ä¿-{†çàczůŽ_–^XþŒ±miB[X±d 1,é”zEù»& î9gœf™9Ð'.;—™i}!ôšåîqêÛ٤ёý£½ÆA–àôe"A$˝Úsäÿ ÷Û #°xŸëí(l »ý3—¥5m! rt`†0~'j2(]S¦¦kv,ÚÇ l¦øJA£Šƒ J3E8ÙiŽ:cÉžúeZ°€¯\®kÖ(79«Ž:¯X”¾³Š&¡* ….‰Ž(ÜíŸ2¥ª‡×Hi²TF¤ò[¨íÈRëÉ䢍mgÑ.Ÿ<öäS0í„ǹÁU´f#Vß;Õ–…P@3ío<ä-±»Ž.L|kªÀê›fÂ6@»eu‚|ÓaÞÆŸ…¨ááå>åŠ?cKü6ùTÍÆ”†sĤÚ;H2RÚ†õ\Ö·Ÿn'¾ ñ#ºI¤Å´%çÁ­‚â7›‹qT3Iï¨ÖÚ5I7Ë!ÅOóŸ¶øÝñØôת¦$Tcö‘[«Ö³šÒ';Aþ ¸èíg A2Z"i¸vdÄ÷.iõ®§)¿]¤À†–‡É&ä{V¶iŽ”.Ó×Õÿ û?h¬Mt–íª[ÿ Ñÿ ÌV(í}=ibÔ¡›¥¢±b Lô¥‡piη_Z<‡z§èŒ)iÖwiÇ 2hÙ3·=’d÷8éŽ1¦¸c¤µ€7›7Ø ð\á)} ¹fËí›pAÃL%âc2 í§æQz¿;T8sæ°qø)QFMð‰XŒÂ±N¢aF¨…8¯!U  Z©RÊ ÖPVÄÀÍin™Ì-GˆªÅËŠ›•zË}º±ŽÍFò¹}Uw×#ä5B¤{î}Ð<ÙD é©¤&‡ïDbàÁôMÁ." ¤‡ú*õ'VŽ|¼´Úgllº¼klz[Æüï÷Aób‡Eÿ dÑ»Xx9ÃÜ£ÁT/`¼¸vI±Ýµ·Ë‚“G³þ*Ÿû´r|*}<¨îºœ @¦mÄ’M¹”.œ«Y–|6ÏU¤jç¥ÕÞqO ˜kDÆÁ¨5ÿ š;ÐЦ¦€GÙk \ –Þ=â¼=SͧµªS°ÚÍpÜãQűÀõ¬?ÃÁ1Ñ•õZà?hóœ€ L¦l{Y*K˜Ù›zc˜–ˆâ ø+¾ ­-Ök¥%ùEÜA'}ˆ><ÊIè“bpÍ/qÞâvoX€w,\úªò6Z[XdÒæ­@Ö—€$òJí#é>'°Ú ôª˜<)4ryÙ£|óAÅn5žêŸyÒäMÝ2{"}‰–¤l÷ûWX\l¾Á¸góÉOÔ /óñB¤f¸çñ[.P˜ZsÊË*ßT܈§QN¢’¡¨§V¼(Üù*eÕ“”5T¨‹Âê¥FŒã½Dü[8'Ò¥a…Ú¶k7a *•›¼'Ò·\8¨ª\@\õ¢¦íq+DÙrmÎ…_ªæ»ŠÓœ¡¯’Ré9MÅ×D™lælffc+ŒÑ,ý™ÿ ¯þǤ=Å’Á7µ÷ÚÛ/“Ü€ñýã¼àí¾ÕÑ+ƒ,uµMâÀÄbm:ÒÎPæ{˜Gz[ƒ¯«® KHà`ߨŠéí¯P8Aq.C‰ à€kòpj´kN¶qô€…Õ,ÜNŠª-­{Zö’æû44‰sŽè‰îVíRœÕm" 6?³D9¡ÇTíÅꋇ`4«¸ÝÁô ï’ýorqКÇZ«x4Žâéþuïf¹µö[P ,Q£éaX±`PÉÍZ ¸äYúg üAx ’6Lê‚xÝÓ*äQ  Ï’¨hÍ =²,6ï#rÃ<¯–£»ƒ‹,–ê•€ aÛsñ'%Æ"®ÛüìBᝠHÚ3ß°©$“XnœÖ’î2ËTeûìxîß ¦å¿çÉ ðK§þ{‘t‚Ϋ¬jéîZ[ ”š7L¥4VÚCE×]m¤Øy”ä4-dz£œ§¸x.*ãÊÊ b÷•h:©‡¦s`BTÁRû¾g⻩‹jø sF¢àJøFl‘È•Xᓁà~*j¯ +(ÚÕ6-£¯÷GŠØy‚<Ç’.F‹Hœw(+)ÜÜâÈzÄäT§FߘãÏ;DmVœ3Àu@mÚüXÝü•3B¨òÌÁÛ<·ÃÜ z,Ì@õÅ·d2]ü8s÷IôÞ¯^Ç9¢u„~ëAŸï4«M? K]­ÅàPl@s_ p:°¬ZR”´›JC[CS.h‹ƒïËœ«Æ]–÷ó‚wR×k7X‰k›‘´ù¦=¡«‰¨¨Â')—71ó’c‡Ðúµ `é.{§p¹ój\Ž{1h{o±Ý=áUÊïGÖŒõ–-BÄm+AZX¶¡ ïHðæ¥JmÙ;…䡟ˆ¦ ° äšiÉg«$üMk5¤L“’çÊvïâï ,=f“"íἊ5ô¬x6{ɏžID0e¸vçmi'︧ºð9$ò¹÷*£’9ÿ ²TÔ…×>JV¥}Œ}$p[bÔ®*[jzS*8 ”·T›Í–ñUîƒwo$áè=LT™ç—~ô·¤ÈÚ$榍q‰„+´kFm)ž‹©i–ËqÞŠ‰à¶ü( ‚•§ •°ò·‡#5ª•µÊ﯅¡X¨šÁ*F#TXJÊ ušJVÍ&=iÄs1‚3•'fý§5Ñ<=[íÞ­ PÚ;ѱÌ_~Ä££8rÞ ²w;’hDT°>ÈG¬8Á²ÚzŽ®ò®qZcqJêäÞ-ö[ܘbň±çb“ж31²n×iƒðÕ;1¶þÉ ªX‰,ßqÏ$>•î íZ¥Z 1{ç൵+ƒÕµ¥°T$§K]á»Ûï*·¤tMI’ÂZbŽÕiÒ˜}bÓ0£ª5›¨ [5Ž^ÝœWøÂÝh° ¢OWun£¤5 a2Z.G2³YL]jåtì”ä ÁÓ‘%"©<Ôúʰsº UZvä‡ÄiÆÒM .÷V·™ø#kèýiíÌ–ª)µT[)BˆõÑ xB¾B€ÖT¨.¥~ð@VĶr#¸ü*åZNDŽH;âi ],©£öØpù(šºãö¼T.uCê•4@ÿ GÕÛ)Cx›®0ø#:ÏðFÒbR\(€€Ä®fã4Þ‰Fä¯HXƒÅ,†öEÑÔÜ]Öv²?tLÃvBY£ú6Êu5ÅAQ³1‘’¬x–HŒÐ‡ ^ ¸KwJôÖŽ5×CÚ¨vÜ«/B0$×k°=ðbÇ(Ï)w±A†Á† 11Í=èQšµ626ŒÜ/`G«µ<}—-Ö7KEHÈÉðóȤmݱû±·ø«Snmá=“䫚mݱŸ¡¶~ó·“äUóJæúòB|E LêŽy´jDÔ$G¢þÐñ7óR8ýÒ…Ç› WVe#·Ÿ p·Fx~•ݤF÷0Èÿ K¯æS<6’¡WШ; ´ÿ ¥Êø\Òuî†åÝ–VNœkÒ7oòX¨Á­Ø÷FÎÑä±g÷ÿ M~Çî=p,X´ ÝÌÚÅ‹’ÃjÖ.ØöÏñ qïQ¤ÓZE†° =6·]܈ s¸>v•Ž^Ý\wq9r‰Î\¸¡kURÒ$­*‹Nq?Þª*!sŠÆ:TU_u±T+øX¡ ®¹¡,ÄâÃBTsÜ$Ø›4m椴zÜK]’’›Pƒ @€#â˜`é¹=I‡fiV•Ôî“nRm+µFPOhÍ0B£ €+¬5c v•:P'ÒyÎ ‰V~‚Ó†ÖuókDoh$å\*ö%Ю=£«…aȼ½÷Û.-½VŒŠ¼'lyî±1¬3ó#ÞE¿ÔS¤gV£m›=§\û"—WU¤ÚǼÿ ÂnÁGŒÃ ‚õN D³õNÚíŒÕ;HôyÄÈ©P¹Ä{:?R‘Ô¨âF÷ø£bÅó® JS|‚R÷ivýáâ€Æé¡è³´IئÑT!§˜•ت‚¬â@q€wnïCWÄ@JU€ê¯m6]Ï:£âx'+ÒðXvÓ¦Úm=–´7œ $ì“B£~p%ÕŸUþ« N@¼üï~w˜ñø5®—'Ôe»¤5ã//€ž~‰Tþ›Å7•#¤× Íö pÄ$ùeåì*«ÓŠEØWEÈsßg ¦ûvžSsLpºÊW–âµEWöˬH; ™!CYõZ ÃÄf æ#1W. \uWâ\,\Çf j’<qTbên›Î[vxx£ë 'ö¨1›˜ÀM¼Pÿ H)ƒêêŒA7s,|F“ 꺸k³9Ìö*ç®;Ö!Ö$Eiž•¹ÒÚ†ýóéÝû¾ÕS®ó$’NÝäŸz¤5r¦ãÄÃD÷Üø!°ø‡Ô&@m™Ì^Ãä­d q5Lnÿ N;.6½·N|#ä"1Nƒx“ã<3('&ñßt  ~ªu”1Tb㫨9ê–›–bìd$ߣ=#ÕãÒmU¯eí$EFù5ýYô櫨æì™Ç—±ssM]·á¿0ÕåJRÓªîiƒ+O58ÖñªŠÒx" \µâá¨i’¤i —Ö ” M+M¤ë9‚‰A¦°Qõ¾ßøK~¼Ã‘g…Ö´~÷Ï[3GUœÒ½#…kàÔ®Ò”‰³·dWV‰IP‰Ú8u¹”E ÖqLj¾êÕCBš{A^Âß;–¨`¯¬ìö ˼ ×tìø.tƐm*n¨y4o&Àx¥n¦×î‡aupáÛj8¿m›è¶ã!o½;ß0y^ý×^EÑ¿ÒjzŒ­)vÚÑnÄL …^ªô× ‡—‚3k Îý­hï]içå–îÏ*÷ñþ»Ô CÒjøjÍznˆ´ ¹#b'Fô‹ ‰v¥'’à'T´ƒHýÍ%M‰ ƒ&ÆÇŒï1 ‘ –Þ ‰i¬s žR-Ÿ kЬá¬7:þ 0ŒÅÒÕ/aÙ¬ÃÝ#Úøœ ©aiVc‰. ¹¦ãµ” ›Yg¦›ÆÎýº°f³7ƒhá·¸­}&D9¡ÂsÉÙÞèŠõØàC™¨ñbFC|´Ü(ŸƒÚÒ-%»'a Ì¿)ËÇn¿úÿ ÞŽX…4ÊÅH^ôΑí@ù¹Eh¶“L8Çjù ¼ÎåVªóR©Ï5uà V4lZß®=€xÖŸ–ÑÈ ÷”¨°¾__yM1tÉ?uÆþIkÄgæ@þ[¢†°XÃJ£j·:nkÅ¢u ‘}âGzö­/IµèЬ¼48q¦F°ŽR¼=ûì{´¯RýicS ÕÛ íNtÍÙï£,w4rêì®»~x(©Uñ§#Ñ&œÕ¤>ÎåÍÓ9’Ö{9eV­[Öjâ²ãu]˜å2›qÑšÕJç0€sÄ|Êëè0튔bÁ>“{×_F`Ø©ºê:µä,v¤ðfc1±"«ÔÍän1#=· Âøv~H½ÐßA¾¿Ü€Óš]Õ; I¾÷ç‚Qi†î¹9ywÔKG˜áñ zQY—§ÃÕZ07§X‚ Áh;ÁM)iÌCH-¯T‘ë|A0{Ò½LÚ–TâÖkÜ’dÀ“rmm»”جPF³ÖcbE§T€ÒxKºû’Ó®7±²(\4ŽÃ¸Uu@j™yĵ;³µ!Á¢b.W¤=mõ´êµK k ¸K^ÜÛ#p*Ü14qkZç5ïë †°5Ï%ÍÛ<Õ¤×Ô¥ê†C Õ´¼ú$ƒÖ“”]Ù¬qÞÚ[4©ý!ûÏ—Áb쳐XµA¬â~`›Çr¸8ìùÝ䫦<>ä÷«?xs´ÇÑ /á;¹øüÊÈÙà{"@Žïzâ¬[âß‚ U_<ÇŸ½4èN˜ú61®qŠu ¦þF£»äJ_ˆÙÎ~ ÞAã–݄ϗrŠD;xTž‘ô`É«…suãO`?³à™ô Lý#Íc5öoæØ‚y´´÷«ZR§<&JÇ+éâô´€i!Àˆ0æAoàðLèÖ-2ŸõW.’t^–(KÁmHµV@xÜÇy®Ñø­â^:Ú3w· 7½¹°ñ¸â¹®:',«Mœ—n­Á+Ãbš LÈ‘ÄnRÓÅœ%¦²‰¨ùQ:¤f‚ "PÕtô¸…cæl…&˜Ú˜Ôkv‹ž+vŠ,=¢v­6—Xy*¥t£«<™:“aîϲ=¦6rO]XI¿Œ÷¤zÚ­›¶ 6÷”w\d ü~v®ˆÌk«^m<ÿ ¢‰Õ\)ùºŽ;… lîÙÅEŠ®cѾ@vnMÏ,¼“ñ•ŽBxðÃzãÇç%3ˆ"}Ù•Åî> BÉú;Ò]V+P˜F_´ßé> Øše|ï‡ÄOmFæÇ ãqÞ$/xÐx­z`ï9"œÜij‚!7.\Td…9M‡•iŽ‹¾‘50ÞŽn¥ß4ÉôO ¹*í^QêËÜÇÌ8=ާs‰'ÂëÙ«á%Pú[O †ÅP¯Vsް.‰,kc¶ ¬A9n˜XÎ-ÞšN["¹QÕ‰ƒMýÁߺXJæÍaLj¾×Ãmã¾ãÚ uñÒþåQô¦¥ /ÄUx:‚ÍÜ’ Đ©ØÝ3V¨‰ÕnÐ6ó*óúK­«…c ¯U òhsý­jóÔj#,ímŒRµ«lbïUTŒÑ8†Ä0œÏr`ð¡¬É Ї ë"À² ™ 6¥ f¶ ¢ÚoܱԷ-<Àî)†a¶ž'Ú»¨TXqØæ¶÷YÄHy˜9ÈIW­YÀuMFë ºÏ’AqÌ4·/Ú †ô'i$øä­=Ä Ý|öK×40è|È6p‘0§)o¥ctî§H+CA-“ xØ|ÐXАç l8íºð3Ø:³¤¬KX¯UÿÙ /** internal * class ActionContainer * * Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]] **/ 'use strict'; var format = require('util').format; // Constants var c = require('./const'); var $$ = require('./utils'); //Actions var ActionHelp = require('./action/help'); var ActionAppend = require('./action/append'); var ActionAppendConstant = require('./action/append/constant'); var ActionCount = require('./action/count'); var ActionStore = require('./action/store'); var ActionStoreConstant = require('./action/store/constant'); var ActionStoreTrue = require('./action/store/true'); var ActionStoreFalse = require('./action/store/false'); var ActionVersion = require('./action/version'); var ActionSubparsers = require('./action/subparsers'); // Errors var argumentErrorHelper = require('./argument/error'); /** * new ActionContainer(options) * * Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]] * * ##### Options: * * - `description` -- A description of what the program does * - `prefixChars` -- Characters that prefix optional arguments * - `argumentDefault` -- The default value for all arguments * - `conflictHandler` -- The conflict handler to use for duplicate arguments **/ var ActionContainer = module.exports = function ActionContainer(options) { options = options || {}; this.description = options.description; this.argumentDefault = options.argumentDefault; this.prefixChars = options.prefixChars || ''; this.conflictHandler = options.conflictHandler; // set up registries this._registries = {}; // register actions this.register('action', null, ActionStore); this.register('action', 'store', ActionStore); this.register('action', 'storeConst', ActionStoreConstant); this.register('action', 'storeTrue', ActionStoreTrue); this.register('action', 'storeFalse', ActionStoreFalse); this.register('action', 'append', ActionAppend); this.register('action', 'appendConst', ActionAppendConstant); this.register('action', 'count', ActionCount); this.register('action', 'help', ActionHelp); this.register('action', 'version', ActionVersion); this.register('action', 'parsers', ActionSubparsers); // raise an exception if the conflict handler is invalid this._getHandler(); // action storage this._actions = []; this._optionStringActions = {}; // groups this._actionGroups = []; this._mutuallyExclusiveGroups = []; // defaults storage this._defaults = {}; // determines whether an "option" looks like a negative number // -1, -1.5 -5e+4 this._regexpNegativeNumber = new RegExp('^[-]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$'); // whether or not there are any optionals that look like negative // numbers -- uses a list so it can be shared and edited this._hasNegativeNumberOptionals = []; }; // Groups must be required, then ActionContainer already defined var ArgumentGroup = require('./argument/group'); var MutuallyExclusiveGroup = require('./argument/exclusive'); // // Registration methods // /** * ActionContainer#register(registryName, value, object) -> Void * - registryName (String) : object type action|type * - value (string) : keyword * - object (Object|Function) : handler * * Register handlers **/ ActionContainer.prototype.register = function (registryName, value, object) { this._registries[registryName] = this._registries[registryName] || {}; this._registries[registryName][value] = object; }; ActionContainer.prototype._registryGet = function (registryName, value, defaultValue) { if (arguments.length < 3) { defaultValue = null; } return this._registries[registryName][value] || defaultValue; }; // // Namespace default accessor methods // /** * ActionContainer#setDefaults(options) -> Void * - options (object):hash of options see [[Action.new]] * * Set defaults **/ ActionContainer.prototype.setDefaults = function (options) { options = options || {}; for (var property in options) { if ($$.has(options, property)) { this._defaults[property] = options[property]; } } // if these defaults match any existing arguments, replace the previous // default on the object with the new one this._actions.forEach(function (action) { if ($$.has(options, action.dest)) { action.defaultValue = options[action.dest]; } }); }; /** * ActionContainer#getDefault(dest) -> Mixed * - dest (string): action destination * * Return action default value **/ ActionContainer.prototype.getDefault = function (dest) { var result = $$.has(this._defaults, dest) ? this._defaults[dest] : null; this._actions.forEach(function (action) { if (action.dest === dest && $$.has(action, 'defaultValue')) { result = action.defaultValue; } }); return result; }; // // Adding argument actions // /** * ActionContainer#addArgument(args, options) -> Object * - args (String|Array): argument key, or array of argument keys * - options (Object): action objects see [[Action.new]] * * #### Examples * - addArgument([ '-f', '--foo' ], { action: 'store', defaultValue: 1, ... }) * - addArgument([ 'bar' ], { action: 'store', nargs: 1, ... }) * - addArgument('--baz', { action: 'store', nargs: 1, ... }) **/ ActionContainer.prototype.addArgument = function (args, options) { args = args; options = options || {}; if (typeof args === 'string') { args = [ args ]; } if (!Array.isArray(args)) { throw new TypeError('addArgument first argument should be a string or an array'); } if (typeof options !== 'object' || Array.isArray(options)) { throw new TypeError('addArgument second argument should be a hash'); } // if no positional args are supplied or only one is supplied and // it doesn't look like an option string, parse a positional argument if (!args || args.length === 1 && this.prefixChars.indexOf(args[0][0]) < 0) { if (args && !!options.dest) { throw new Error('dest supplied twice for positional argument'); } options = this._getPositional(args, options); // otherwise, we're adding an optional argument } else { options = this._getOptional(args, options); } // if no default was supplied, use the parser-level default if (typeof options.defaultValue === 'undefined') { var dest = options.dest; if ($$.has(this._defaults, dest)) { options.defaultValue = this._defaults[dest]; } else if (typeof this.argumentDefault !== 'undefined') { options.defaultValue = this.argumentDefault; } } // create the action object, and add it to the parser var ActionClass = this._popActionClass(options); if (typeof ActionClass !== 'function') { throw new Error(format('Unknown action "%s".', ActionClass)); } var action = new ActionClass(options); // throw an error if the action type is not callable var typeFunction = this._registryGet('type', action.type, action.type); if (typeof typeFunction !== 'function') { throw new Error(format('"%s" is not callable', typeFunction)); } return this._addAction(action); }; /** * ActionContainer#addArgumentGroup(options) -> ArgumentGroup * - options (Object): hash of options see [[ArgumentGroup.new]] * * Create new arguments groups **/ ActionContainer.prototype.addArgumentGroup = function (options) { var group = new ArgumentGroup(this, options); this._actionGroups.push(group); return group; }; /** * ActionContainer#addMutuallyExclusiveGroup(options) -> ArgumentGroup * - options (Object): {required: false} * * Create new mutual exclusive groups **/ ActionContainer.prototype.addMutuallyExclusiveGroup = function (options) { var group = new MutuallyExclusiveGroup(this, options); this._mutuallyExclusiveGroups.push(group); return group; }; ActionContainer.prototype._addAction = function (action) { var self = this; // resolve any conflicts this._checkConflict(action); // add to actions list this._actions.push(action); action.container = this; // index the action by any option strings it has action.optionStrings.forEach(function (optionString) { self._optionStringActions[optionString] = action; }); // set the flag if any option strings look like negative numbers action.optionStrings.forEach(function (optionString) { if (optionString.match(self._regexpNegativeNumber)) { if (!self._hasNegativeNumberOptionals.some(Boolean)) { self._hasNegativeNumberOptionals.push(true); } } }); // return the created action return action; }; ActionContainer.prototype._removeAction = function (action) { var actionIndex = this._actions.indexOf(action); if (actionIndex >= 0) { this._actions.splice(actionIndex, 1); } }; ActionContainer.prototype._addContainerActions = function (container) { // collect groups by titles var titleGroupMap = {}; this._actionGroups.forEach(function (group) { if (titleGroupMap[group.title]) { throw new Error(format('Cannot merge actions - two groups are named "%s".', group.title)); } titleGroupMap[group.title] = group; }); // map each action to its group var groupMap = {}; function actionHash(action) { // unique (hopefully?) string suitable as dictionary key return action.getName(); } container._actionGroups.forEach(function (group) { // if a group with the title exists, use that, otherwise // create a new group matching the container's group if (!titleGroupMap[group.title]) { titleGroupMap[group.title] = this.addArgumentGroup({ title: group.title, description: group.description }); } // map the actions to their new group group._groupActions.forEach(function (action) { groupMap[actionHash(action)] = titleGroupMap[group.title]; }); }, this); // add container's mutually exclusive groups // NOTE: if add_mutually_exclusive_group ever gains title= and // description= then this code will need to be expanded as above var mutexGroup; container._mutuallyExclusiveGroups.forEach(function (group) { mutexGroup = this.addMutuallyExclusiveGroup({ required: group.required }); // map the actions to their new mutex group group._groupActions.forEach(function (action) { groupMap[actionHash(action)] = mutexGroup; }); }, this); // forEach takes a 'this' argument // add all actions to this container or their group container._actions.forEach(function (action) { var key = actionHash(action); if (groupMap[key]) { groupMap[key]._addAction(action); } else { this._addAction(action); } }); }; ActionContainer.prototype._getPositional = function (dest, options) { if (Array.isArray(dest)) { dest = dest[0]; } // make sure required is not specified if (options.required) { throw new Error('"required" is an invalid argument for positionals.'); } // mark positional arguments as required if at least one is // always required if (options.nargs !== c.OPTIONAL && options.nargs !== c.ZERO_OR_MORE) { options.required = true; } if (options.nargs === c.ZERO_OR_MORE && typeof options.defaultValue === 'undefined') { options.required = true; } // return the keyword arguments with no option strings options.dest = dest; options.optionStrings = []; return options; }; ActionContainer.prototype._getOptional = function (args, options) { var prefixChars = this.prefixChars; var optionStrings = []; var optionStringsLong = []; // determine short and long option strings args.forEach(function (optionString) { // error on strings that don't start with an appropriate prefix if (prefixChars.indexOf(optionString[0]) < 0) { throw new Error(format('Invalid option string "%s": must start with a "%s".', optionString, prefixChars )); } // strings starting with two prefix characters are long options optionStrings.push(optionString); if (optionString.length > 1 && prefixChars.indexOf(optionString[1]) >= 0) { optionStringsLong.push(optionString); } }); // infer dest, '--foo-bar' -> 'foo_bar' and '-x' -> 'x' var dest = options.dest || null; delete options.dest; if (!dest) { var optionStringDest = optionStringsLong.length ? optionStringsLong[0] : optionStrings[0]; dest = $$.trimChars(optionStringDest, this.prefixChars); if (dest.length === 0) { throw new Error( format('dest= is required for options like "%s"', optionStrings.join(', ')) ); } dest = dest.replace(/-/g, '_'); } // return the updated keyword arguments options.dest = dest; options.optionStrings = optionStrings; return options; }; ActionContainer.prototype._popActionClass = function (options, defaultValue) { defaultValue = defaultValue || null; var action = (options.action || defaultValue); delete options.action; var actionClass = this._registryGet('action', action, action); return actionClass; }; ActionContainer.prototype._getHandler = function () { var handlerString = this.conflictHandler; var handlerFuncName = '_handleConflict' + $$.capitalize(handlerString); var func = this[handlerFuncName]; if (typeof func === 'undefined') { var msg = 'invalid conflict resolution value: ' + handlerString; throw new Error(msg); } else { return func; } }; ActionContainer.prototype._checkConflict = function (action) { var optionStringActions = this._optionStringActions; var conflictOptionals = []; // find all options that conflict with this option // collect pairs, the string, and an existing action that it conflicts with action.optionStrings.forEach(function (optionString) { var conflOptional = optionStringActions[optionString]; if (typeof conflOptional !== 'undefined') { conflictOptionals.push([ optionString, conflOptional ]); } }); if (conflictOptionals.length > 0) { var conflictHandler = this._getHandler(); conflictHandler.call(this, action, conflictOptionals); } }; ActionContainer.prototype._handleConflictError = function (action, conflOptionals) { var conflicts = conflOptionals.map(function (pair) { return pair[0]; }); conflicts = conflicts.join(', '); throw argumentErrorHelper( action, format('Conflicting option string(s): %s', conflicts) ); }; ActionContainer.prototype._handleConflictResolve = function (action, conflOptionals) { // remove all conflicting options var self = this; conflOptionals.forEach(function (pair) { var optionString = pair[0]; var conflictingAction = pair[1]; // remove the conflicting option string var i = conflictingAction.optionStrings.indexOf(optionString); if (i >= 0) { conflictingAction.optionStrings.splice(i, 1); } delete self._optionStringActions[optionString]; // if the option now has no option string, remove it from the // container holding it if (conflictingAction.optionStrings.length === 0) { conflictingAction.container._removeAction(conflictingAction); } }); };