����C %# , #&')*)-0-(0%()(��C (((((((((((((((((((((((((((((((((((((((((((((((((((����"�������@�@�hC��}!���Ѱ��<"� 9iׂIIIHk�+?�c?��*Y�����!�du)b�T�9вU�$8G��I.�澬��D���Sq� q�}.<��Z�l�V!X� *x�-�\����t3i�Ũ�sNv71�ƛ\��z|t�L���$�����*f��kʮ��7�H;���~F%�'3�@�H�q�` 9mOL����/x@ @��G
d�8F�ه��Ka�Kdr�Fh.�]y4 JЛ��]�K�B�E$��$ $ �PR�����G�]��u�i$�$���'! "#031���C/Td=S�Q?���62Ccj{ ����̏d�چ/c�V�`��Wz͈�{Y`�d�h�L �]OB���l���o���mr���n��s-ڗEZ��N�_��1%b���H�ϣ������V�7):�ӷ)�}�~�(�;�!�b1�5K��[E�vϻ>��q.%� ���O���(�c�#x�$�'+��`٥v��v(�����M�"�v��B��.�a ���T�~�ϕ�hy(6nݱl��1yNɓx�������AR�8�rqv1.cS�+��_���&@�� �u�M�5Ĉ�Xm���eL�X�q��y#�9]�c�}ɄL��d�eJ몓���I1T�d��CaM�$��T�,�X �bʭ�!�%F5��X1x#���!�q��\��F��2��&Rq���C�ol~�̱�.0ϦL�d�`.������ ���m{�Y~k{C��}bv�;U��c<�r�~ɜs�1�j��]W�l��*նCr��Q�N9�-������d��E؛��nF��eړ�8(q��5UgRȱGTA��*������̆��V�珰����ezN��h�U]�T�FG�^���<��ay�,!���5.� �u�bΚ�V�J%��m�Dxn'�����6�@BPa�`��Hts� �ɮ���Ŏ�Zɬ��%B�X��d5Z���hC}�䅸�p+ k=��ʒ(�aՏFG&�%@/�{+�Yu+�ȣGѩ"O%�|vȲxF>�N(��ou�h6 &Y5��8�7�E$-��']n,@TD\��+���Ry�U��U^�Q,f>��1�����q��f��U��� ����F���ڥ��>I�����fNUw�u��#OMMQ6� N�*��_�� k� ����rS��`���1�:��!�F'<+� � b?O��2 !Q12A��� "3a������#$��?�,�7�!`yǮ(�1�6w��a���� �F�#��?*"s���v>��Ⱥ����f�v��͑���s����������]Gn��S ���ȥpG ы�E�g�)Z���x�rY�q�]�@f�_܃�pչEڎّC ����Ŝ*/ �h�O�Sv�و\��5��U��y��|o�Hm2C�S�BW����)��5��{T��W���=o*RA��<����L0g4{��쁢�ep�rw�8��7��U���t<Ԍѻ7�fGf�k}���Ê�㛆Gռz�Q@��{C��'G��8�!�S$�j��x���|���צV<��,����u�k�uu�rM�f�_dϣi ߫�ԟn�!K����mxu�=�槻�'j�X�����������%!A "1QR#Br��?�R:��R�n�b[�II?#��6<:�$gN����lGNlrr��dעMMn`ɿy�,�%B�e�W��dVS��r���� %�tT��(�ɷ��S�]�O]#�_LEMHN�M���kv���~X���O6�U�V_�����b���J�t�774����D!1AQa"2q�#3BRb����0���� 4CSr����cst�����?��^q���7�dG�U�"p��moz��'��n_x���唹e������<6��O�t���R>k��s=�Cr���e�?�i��� ����/��ں$be���o`ޮ�GHy�;fNAl�8��.�\�S������"���a�úF�YvNk�-*`v�k�ʈ2f�EE��Wa�,� �fF^#�;��[9��^~������Y$:0#W3������Z*���I�Z�ڹ�k�n--9=��G��;7F)m{T�Ɇ��=�����Ȭ5�5�B�aڞ5M����#m�5Ʀ��m�8��+Hh���$�}�:&�e�Q�[;i]С�:�:��o����$<~��5RB�?�s3�5�r��O��ֿ�w�P/��̅���(�Z6�R>)��N��4�!ʊ�wz�-�r�w+�yk���q�1�bKhƸ�4N�Ӑ�X����Q��_��})�+e1�5��n��q?��[�^�9�<�z3Fsi�8�'�)9p)�{��RP�Z+�*��p(aY��V����6l�g�9��;���d�u���Nt@�3�sTwzaŇ�GT�b�H��(#��*zc�������9K�b1�����t����Ê��
�Z?g�iD���H�R���B���^M����v���O���L�D,'d�q�C�P�����$Δ��U�֟֊=�s��F�$��J�ދZ?�N��������A�N�WP��,�� �¦�&;�x��dup�����i���Ipd���;�Dž!��ֿѮAb%�u��}j��-p��>I�[�N�bi����G�'�;4w�m]H�]����#LӘNN��R��������s�.]��en��-�8e��Ps����Q��;���ț�E�ݫ���7��g�_L��W��EZ:/��I���a�g�n�ܤ��iٹ���ŷ�T���H~i�a�����֎�~KV������ A-2m]�F"�m�9-Zbǰ�״ @����~�4�N�[�Uxč�tl>������u#r�gѐ�3���;M9�<�J�����1�vfL8����1�P�HgP�Xv��������{����O�}�n��KQ؋����7<�l�fey<�}�>�bX���4<`Y7���si��V)�s�:�{�rO�h�z �@4VW�B���&�������ɡob܋�F��4>y�s�fXWS�N�O$�,.u:�ԫ��g�yao4��$h��D#��ٸf^kh�7�#1Z�֥&���*�v-��;bޭ����Q�����h�ow�y]�ه.+�7�M�ⴻ �JY��g�f�i3q��KC��3�¹�?5�Z.N��^Z w���KF͂���7��ރ۞��wj��T�J.�q��\Sv1U����R��욽&�N����pЖ`�`у��m`v�n#z��4��>e��V�`'���h�����'�j�AҔ�-�4:H���n]9�h<��n����U�6m��2c�E�1/�Y�%���I��~ʏ�|VBƟ@����;�������%�M9M���}��1�D��d����%g���O��]��у&�r��f�7�uܲ���(!1AQaq�������0� ���?!��*��@)�Je�G��j��{�['��v+���������)���(�/����д%젍Z��kk�Lu�Rm���j.c���@Z� V�J��d��j���h6���2AO�� a;oBu���H�=���nK�W8�B�ɰ�u?��бأm,�sr����|����8˨i��qI2tZ�ۄJP��XE��������zޔj~]UMu����zv!����N�&�1�Y��zJ�ՠ��\p��o'ሸ�C؊Y��TD"HM5�Ъ��i߯a���F����A)�����ڮ����z�E���@�hg�֝8�1jk��\�M�3�8ܢ�� ������s�7����N}�ޭ������GN�Bc���L pk�;�J�δ3�e�iU�gAYW]\�>�GyگQ=��f�KA;T�a`eM+Q �� �Ln���̌]GM�����<Ħ�j���H��N�M�x�}aX{̣S� ��ԅ��n�MA�S�r�(����(�L��zo9���.�;
�ӳf������`Ӕ٢3�� IW��\9~_���saa�\ԊW�ܭX:���ӆ�38�ty*����N�qP����BI�Y��jE��>DP�!�R%-��4��'�皺;��~J�!�7m���X��h�P!曭���$�\�AYj�.lC��4��+�jD�dgC0-*���|��`ZD�+л�C"��)��s��8Kq�pq���Ms��4� ��7\U`�.��[Ey8��AH!/��,���(:M -�T䓥�~O�4-���Ԓn��}HDN7���K���$�_Ԕ䚞`�R�hB�_aX?4V��ŗ�@ه�u�a�;�{PcT+�������7YBo�?��r-ͩ{�ĎA�� ����˼n��M286��G���1���V�˜Jв"l��V5���5�C]h���̊�A���%� �'p���Ԃ���Ր��9=�d�=�e�{�'<3�_ �:^�~��4�(�n�-C�s��5m![�jmIqU�~�Tw8��`���p�H8�u�Д l m�aP�0�������9y����CM��F1G糞�.�U~�������FC�{�!e(Y�:���P����7~;�L�N^{�1r�\���ԬG(���0d�ÏO�qK�Z�⑼�T�{ 2��s��Kd�Տ?mMQ��=���6�7�i�����H+����9��d��=��;�QؤH8n�Lb�D��yS%�(�{b���Cu���p�t#C���$A"�H{���jqᶯ�:�n=E����hH�`�!�m��MA������?�v6���+MԿ⟚qK�i�D�*Q5��CZ���2�|]�:Xd+�t�:o@��M��� :�32��b����[\5=�ֵ7])�|t��Ϻ����w�B�ń�e���!`�:��I,��9:����j@/a 8����+<�u�(T^ۺ~��2oE�B�%b)��z��ݳځ�)��i�j��&��Fi`qr��w���7�@��P�� �3Z&<�m�S�C����7t�T����ƴ�q~J�e�r6�Z]�rL���ه�E17'�x���+[�ܜTc6�/�����W�`�qpMJ���N5^����x�}{l�Fm������1�oZ\�����/d�/6� �uӸ�0elXuX;M��$M�}mB��������Z%e���3f�js����O�J~2�z�86�*PB��v�Ν��e-��.�/��L�O����2����9���4}|��T5M���hÐ7�F*��l+y0����:|��=k[�d�;|�ԉe�=w�<��õ�<��'!1AQaq����� ������?��5����)�(���+>v����6&{���Ǹ@����M�����v��iA 6T'�w��h�s �E}�x��G&'g�� J~1q�f�f���&��q˘���-���vYm
�/i1 �I��6��u,)�#�,����l}*&`�$�ͬe�%�w3�x�Ѥ�Xc�D��执g�峕�5B/�|$��=���%8 a��2.l� c�@G� �\�/x[өq�]�v5?�����N|�!���\��,>��{�"r�/��?��&!1QAa�� ��ᑱ����?ĊD�肭�� nv@�yޝ (�����I ����U - ���b�m�E>,��1v!�d�&�� ���&�檔�5D�&0P��Ԕ�͒@Z��:E"� Q��`>PH:~�O�����P�3W��@hM��k�U��\�O��R�������5ʄ�,��f�|��r���}јxo)�"+h�QK���/��0�`�5�{M~�� ���'!1AQaq���0 �������?�?�k��#^�~�G��#V,������#Z�1'ܤ����������~p�O%O�O�\�q�`�~��}��E�Ű5 �輸�du����x\�$���s[�{T2t`B��gq�4Z]b� 㛪�3,(@����bAp�r)9:@|b�!r�g:N�^�Ʌ��� �x_�\��pm7I��0?>^k��������w���|.K�[sF@�]Gn*L �yO� le�P�.p��֍�j�S�=�ʨ�ןQF�"��5zʼn���k�*8�u" ����Fg��� �cSy�V������Ƈ��N��ؐ(�����48hV�A�ӎ^��^ ���jyB� ��p"�����y]�ļlU�(�7�U`3�pCGF'&yg������o��z������X��ν:�P"@�G@x[��o&MJ�$F.����hi w;}�/^͇q���n�mN�/�TQ���އ��O1\,}��bQ #¯^S!)��X���#GPȏ�t�� c^\��' }iIZ���a�)��������z��4͊�Ξy��48,��f���#�����KP!Jx�|w�ʆ�������������#��Z�������< �~K��r�p&qH/;�R���沽�+�E�R���~0v���V#ʀ�T��S(-ڝ��B�y�b�C�D������b��������8��~�= �Y�ͧ]��@n����M�k2�%�;�%,�r6�LR腻?^��;KŇ=�ք ���=`�ɥ��/����z�&�I{���#J��M���C��}�H9^UJ�,P ��pS����G�d69Ϭu���%"��ˢP��K�"k)��=��9� ����㇌,��Oli��Xzh� " � ������R��^�s����N�k��Q>�63(���� ��PQ�Py�����3����$f+W՛=4�ǁ`*��^��Eb�K�t�6��^��!�籷��ȭ��K{/;�L���p�x�����;a���Oلz�[�.NP4�]Gc�T�v����~sg'LED��]j��'�G�]�6rY����UPw�*O�İՋi�'8�۴�#g�Xx+=�eU6�R��c�"�u2��~�?n�y�;�u��3�'��6�f������b��߬M�$*��k&?6���*^1n����ێz)<��Gz� �����7����Y� ��ۃ)$A��2�L6� ե�H�<�r��#ʽ2��O��R���z�A��XW��@���������<�G� Ϥ�^�˓i�M�W���6 ��0��m){c�;ݧ�>R�a����}1�ٯ%�EY2�Q��Ep���$ ��E��qS��t#+x� *�h�UI��XM?�'//��a'�G�����q@���<��z��؟����cd��z�ˬT_u�Ѯ����&�z�k ��n ]�a%�py»�`Qd�xc������n�� ��*��oTd�;'j�<�!j���'�(~�ʹW�M� P�mȘ��@֨V+��R�`�$��`�+@��_[�kG����P���Zh9�R����&5b�v���Z���#p�&�Ա+��8�etZ7G���;��@"�e0���v7����?��z�?_���_�q1�T�"�p�ˎ/U 6_�B�>��0( ��}G#������Ȣ�p�� �9��;/& `�B&$�y��t(�*z�x���Ӕ������S�?Kȏ3���{p� b � ۍ-�z܈֦��6?<���ǬP�N�G �更� �6�/h�����0Z���������i�ua��e�*M'A� �x��v�q.>�F� oN{��Q���{gD��L��u��=|���O xN���d���q�8(��E�Uu��,��O� t�DJ ����;��G����e���C��VYZ�� ���T4{����(�Ӳ'c�t�f��w�c�jr�e�m �#7,�6��B�E4Q�P�.P�(&��^{9H-�m�o ��q�g1���=��>p�)/"p0!4�mS6ú�FN���h��D �)��XdT �FؤZ⸚�k���H�c8v� <���u�P�Հ���:��_�EN��|�ӛ��u?-�/�o�Lhk�ܸ�S�;�Rī�����T"�N����M��px7<�� j�$��`�Y)Pjh 5` K�Qf�4�C�bX"�D���;HD�Z�9R b�F)�UA����v�#��HD�!{������>I� �`�ԁ i�4�)t*�ç�Le�_���>ru�GEQg��ǔct��ō0��l6v���d�� ��GG8���v^�|�#JyZPSO�� Y�CuAߐ�"�x���OfHF@�K�V�!少Eҕ]h� ��[���)��.q����*0I<8��^�6�}p��^tho���ig�i����DK���p,��2�3�I��5����쓄OY�6s7Qs�Ow^�w�J/�A➰������0������g(Մ��y��Kԇ����QS��?H���w�X�=��ҞX�~���Q=�'���p?7�@g�~�G�}�r��g�T?���
One Hat Cyber Team
One Hat Cyber Team
Your IP :
172.69.6.45
Server IP :
172.67.155.96
Server :
Linux server3.shared.spaceship.host 4.18.0-553.47.1.lve.el8.x86_64 #1 SMP Tue Apr 8 13:54:31 UTC 2025 x86_64
Server Software :
LiteSpeed
PHP Version :
5.6.40
Buat File
|
Buat Folder
Dir :
~
/
lib
/
node_modules
/
npm
/
node_modules
/
yargs
/
lib
/
Edit File Name:
usage.js
'use strict' // this file handles outputting usage instructions, // failures, etc. keeps logging in one place. const decamelize = require('decamelize') const stringWidth = require('string-width') const objFilter = require('./obj-filter') const path = require('path') const setBlocking = require('set-blocking') const YError = require('./yerror') module.exports = function usage (yargs, y18n) { const __ = y18n.__ const self = {} // methods for ouputting/building failure message. const fails = [] self.failFn = function failFn (f) { fails.push(f) } let failMessage = null let showHelpOnFail = true self.showHelpOnFail = function showHelpOnFailFn (enabled, message) { if (typeof enabled === 'string') { message = enabled enabled = true } else if (typeof enabled === 'undefined') { enabled = true } failMessage = message showHelpOnFail = enabled return self } let failureOutput = false self.fail = function fail (msg, err) { const logger = yargs._getLoggerInstance() if (fails.length) { for (let i = fails.length - 1; i >= 0; --i) { fails[i](msg, err, self) } } else { if (yargs.getExitProcess()) setBlocking(true) // don't output failure message more than once if (!failureOutput) { failureOutput = true if (showHelpOnFail) { yargs.showHelp('error') logger.error() } if (msg || err) logger.error(msg || err) if (failMessage) { if (msg || err) logger.error('') logger.error(failMessage) } } err = err || new YError(msg) if (yargs.getExitProcess()) { return yargs.exit(1) } else if (yargs._hasParseCallback()) { return yargs.exit(1, err) } else { throw err } } } // methods for ouputting/building help (usage) message. let usages = [] let usageDisabled = false self.usage = (msg, description) => { if (msg === null) { usageDisabled = true usages = [] return } usageDisabled = false usages.push([msg, description || '']) return self } self.getUsage = () => { return usages } self.getUsageDisabled = () => { return usageDisabled } self.getPositionalGroupName = () => { return __('Positionals:') } let examples = [] self.example = (cmd, description) => { examples.push([cmd, description || '']) } let commands = [] self.command = function command (cmd, description, isDefault, aliases) { // the last default wins, so cancel out any previously set default if (isDefault) { commands = commands.map((cmdArray) => { cmdArray[2] = false return cmdArray }) } commands.push([cmd, description || '', isDefault, aliases]) } self.getCommands = () => commands let descriptions = {} self.describe = function describe (key, desc) { if (typeof key === 'object') { Object.keys(key).forEach((k) => { self.describe(k, key[k]) }) } else { descriptions[key] = desc } } self.getDescriptions = () => descriptions let epilogs = [] self.epilog = (msg) => { epilogs.push(msg) } let wrapSet = false let wrap self.wrap = (cols) => { wrapSet = true wrap = cols } function getWrap () { if (!wrapSet) { wrap = windowWidth() wrapSet = true } return wrap } const deferY18nLookupPrefix = '__yargsString__:' self.deferY18nLookup = str => deferY18nLookupPrefix + str const defaultGroup = 'Options:' self.help = function help () { if (cachedHelpMessage) return cachedHelpMessage normalizeAliases() // handle old demanded API const base$0 = yargs.customScriptName ? yargs.$0 : path.basename(yargs.$0) const demandedOptions = yargs.getDemandedOptions() const demandedCommands = yargs.getDemandedCommands() const groups = yargs.getGroups() const options = yargs.getOptions() let keys = [] keys = keys.concat(Object.keys(descriptions)) keys = keys.concat(Object.keys(demandedOptions)) keys = keys.concat(Object.keys(demandedCommands)) keys = keys.concat(Object.keys(options.default)) keys = keys.filter(filterHiddenOptions) keys = Object.keys(keys.reduce((acc, key) => { if (key !== '_') acc[key] = true return acc }, {})) const theWrap = getWrap() const ui = require('cliui')({ width: theWrap, wrap: !!theWrap }) // the usage string. if (!usageDisabled) { if (usages.length) { // user-defined usage. usages.forEach((usage) => { ui.div(`${usage[0].replace(/\$0/g, base$0)}`) if (usage[1]) { ui.div({ text: `${usage[1]}`, padding: [1, 0, 0, 0] }) } }) ui.div() } else if (commands.length) { let u = null // demonstrate how commands are used. if (demandedCommands._) { u = `${base$0} <${__('command')}>\n` } else { u = `${base$0} [${__('command')}]\n` } ui.div(`${u}`) } } // your application's commands, i.e., non-option // arguments populated in '_'. if (commands.length) { ui.div(__('Commands:')) const context = yargs.getContext() const parentCommands = context.commands.length ? `${context.commands.join(' ')} ` : '' if (yargs.getParserConfiguration()['sort-commands'] === true) { commands = commands.sort((a, b) => a[0].localeCompare(b[0])) } commands.forEach((command) => { const commandString = `${base$0} ${parentCommands}${command[0].replace(/^\$0 ?/, '')}` // drop $0 from default commands. ui.span( { text: commandString, padding: [0, 2, 0, 2], width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4 }, { text: command[1] } ) const hints = [] if (command[2]) hints.push(`[${__('default:').slice(0, -1)}]`) // TODO hacking around i18n here if (command[3] && command[3].length) { hints.push(`[${__('aliases:')} ${command[3].join(', ')}]`) } if (hints.length) { ui.div({ text: hints.join(' '), padding: [0, 0, 0, 2], align: 'right' }) } else { ui.div() } }) ui.div() } // perform some cleanup on the keys array, making it // only include top-level keys not their aliases. const aliasKeys = (Object.keys(options.alias) || []) .concat(Object.keys(yargs.parsed.newAliases) || []) keys = keys.filter(key => !yargs.parsed.newAliases[key] && aliasKeys.every(alias => (options.alias[alias] || []).indexOf(key) === -1)) // populate 'Options:' group with any keys that have not // explicitly had a group set. if (!groups[defaultGroup]) groups[defaultGroup] = [] addUngroupedKeys(keys, options.alias, groups) // display 'Options:' table along with any custom tables: Object.keys(groups).forEach((groupName) => { if (!groups[groupName].length) return // if we've grouped the key 'f', but 'f' aliases 'foobar', // normalizedKeys should contain only 'foobar'. const normalizedKeys = groups[groupName].filter(filterHiddenOptions).map((key) => { if (~aliasKeys.indexOf(key)) return key for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) { if (~(options.alias[aliasKey] || []).indexOf(key)) return aliasKey } return key }) if (normalizedKeys.length < 1) return ui.div(__(groupName)) // actually generate the switches string --foo, -f, --bar. const switches = normalizedKeys.reduce((acc, key) => { acc[key] = [ key ].concat(options.alias[key] || []) .map(sw => { // for the special positional group don't // add '--' or '-' prefix. if (groupName === self.getPositionalGroupName()) return sw else return (sw.length > 1 ? '--' : '-') + sw }) .join(', ') return acc }, {}) normalizedKeys.forEach((key) => { const kswitch = switches[key] let desc = descriptions[key] || '' let type = null if (~desc.lastIndexOf(deferY18nLookupPrefix)) desc = __(desc.substring(deferY18nLookupPrefix.length)) if (~options.boolean.indexOf(key)) type = `[${__('boolean')}]` if (~options.count.indexOf(key)) type = `[${__('count')}]` if (~options.string.indexOf(key)) type = `[${__('string')}]` if (~options.normalize.indexOf(key)) type = `[${__('string')}]` if (~options.array.indexOf(key)) type = `[${__('array')}]` if (~options.number.indexOf(key)) type = `[${__('number')}]` const extra = [ type, (key in demandedOptions) ? `[${__('required')}]` : null, options.choices && options.choices[key] ? `[${__('choices:')} ${ self.stringifiedValues(options.choices[key])}]` : null, defaultString(options.default[key], options.defaultDescription[key]) ].filter(Boolean).join(' ') ui.span( { text: kswitch, padding: [0, 2, 0, 2], width: maxWidth(switches, theWrap) + 4 }, desc ) if (extra) ui.div({ text: extra, padding: [0, 0, 0, 2], align: 'right' }) else ui.div() }) ui.div() }) // describe some common use-cases for your application. if (examples.length) { ui.div(__('Examples:')) examples.forEach((example) => { example[0] = example[0].replace(/\$0/g, base$0) }) examples.forEach((example) => { if (example[1] === '') { ui.div( { text: example[0], padding: [0, 2, 0, 2] } ) } else { ui.div( { text: example[0], padding: [0, 2, 0, 2], width: maxWidth(examples, theWrap) + 4 }, { text: example[1] } ) } }) ui.div() } // the usage string. if (epilogs.length > 0) { const e = epilogs.map(epilog => epilog.replace(/\$0/g, base$0)).join('\n') ui.div(`${e}\n`) } // Remove the trailing white spaces return ui.toString().replace(/\s*$/, '') } // return the maximum width of a string // in the left-hand column of a table. function maxWidth (table, theWrap, modifier) { let width = 0 // table might be of the form [leftColumn], // or {key: leftColumn} if (!Array.isArray(table)) { table = Object.keys(table).map(key => [table[key]]) } table.forEach((v) => { width = Math.max( stringWidth(modifier ? `${modifier} ${v[0]}` : v[0]), width ) }) // if we've enabled 'wrap' we should limit // the max-width of the left-column. if (theWrap) width = Math.min(width, parseInt(theWrap * 0.5, 10)) return width } // make sure any options set for aliases, // are copied to the keys being aliased. function normalizeAliases () { // handle old demanded API const demandedOptions = yargs.getDemandedOptions() const options = yargs.getOptions() ;(Object.keys(options.alias) || []).forEach((key) => { options.alias[key].forEach((alias) => { // copy descriptions. if (descriptions[alias]) self.describe(key, descriptions[alias]) // copy demanded. if (alias in demandedOptions) yargs.demandOption(key, demandedOptions[alias]) // type messages. if (~options.boolean.indexOf(alias)) yargs.boolean(key) if (~options.count.indexOf(alias)) yargs.count(key) if (~options.string.indexOf(alias)) yargs.string(key) if (~options.normalize.indexOf(alias)) yargs.normalize(key) if (~options.array.indexOf(alias)) yargs.array(key) if (~options.number.indexOf(alias)) yargs.number(key) }) }) } // if yargs is executing an async handler, we take a snapshot of the // help message to display on failure: let cachedHelpMessage self.cacheHelpMessage = function () { cachedHelpMessage = this.help() } // given a set of keys, place any keys that are // ungrouped under the 'Options:' grouping. function addUngroupedKeys (keys, aliases, groups) { let groupedKeys = [] let toCheck = null Object.keys(groups).forEach((group) => { groupedKeys = groupedKeys.concat(groups[group]) }) keys.forEach((key) => { toCheck = [key].concat(aliases[key]) if (!toCheck.some(k => groupedKeys.indexOf(k) !== -1)) { groups[defaultGroup].push(key) } }) return groupedKeys } function filterHiddenOptions (key) { return yargs.getOptions().hiddenOptions.indexOf(key) < 0 || yargs.parsed.argv[yargs.getOptions().showHiddenOpt] } self.showHelp = (level) => { const logger = yargs._getLoggerInstance() if (!level) level = 'error' const emit = typeof level === 'function' ? level : logger[level] emit(self.help()) } self.functionDescription = (fn) => { const description = fn.name ? decamelize(fn.name, '-') : __('generated-value') return ['(', description, ')'].join('') } self.stringifiedValues = function stringifiedValues (values, separator) { let string = '' const sep = separator || ', ' const array = [].concat(values) if (!values || !array.length) return string array.forEach((value) => { if (string.length) string += sep string += JSON.stringify(value) }) return string } // format the default-value-string displayed in // the right-hand column. function defaultString (value, defaultDescription) { let string = `[${__('default:')} ` if (value === undefined && !defaultDescription) return null if (defaultDescription) { string += defaultDescription } else { switch (typeof value) { case 'string': string += `"${value}"` break case 'object': string += JSON.stringify(value) break default: string += value } } return `${string}]` } // guess the width of the console window, max-width 80. function windowWidth () { const maxWidth = 80 if (typeof process === 'object' && process.stdout && process.stdout.columns) { return Math.min(maxWidth, process.stdout.columns) } else { return maxWidth } } // logic for displaying application version. let version = null self.version = (ver) => { version = ver } self.showVersion = () => { const logger = yargs._getLoggerInstance() logger.log(version) } self.reset = function reset (localLookup) { // do not reset wrap here // do not reset fails here failMessage = null failureOutput = false usages = [] usageDisabled = false epilogs = [] examples = [] commands = [] descriptions = objFilter(descriptions, (k, v) => !localLookup[k]) return self } let frozens = [] self.freeze = function freeze () { let frozen = {} frozens.push(frozen) frozen.failMessage = failMessage frozen.failureOutput = failureOutput frozen.usages = usages frozen.usageDisabled = usageDisabled frozen.epilogs = epilogs frozen.examples = examples frozen.commands = commands frozen.descriptions = descriptions } self.unfreeze = function unfreeze () { let frozen = frozens.pop() failMessage = frozen.failMessage failureOutput = frozen.failureOutput usages = frozen.usages usageDisabled = frozen.usageDisabled epilogs = frozen.epilogs examples = frozen.examples commands = frozen.commands descriptions = frozen.descriptions } return self }
Save