Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

index.js 860B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict'
  2. // classic singleton yargs API, to use yargs
  3. // without running as a singleton do:
  4. // require('yargs/yargs')(process.argv.slice(2))
  5. const yargs = require('./yargs')
  6. Argv(process.argv.slice(2))
  7. module.exports = Argv
  8. function Argv (processArgs, cwd) {
  9. const argv = yargs(processArgs, cwd, require)
  10. singletonify(argv)
  11. return argv
  12. }
  13. /* Hack an instance of Argv with process.argv into Argv
  14. so people can do
  15. require('yargs')(['--beeble=1','-z','zizzle']).argv
  16. to parse a list of args and
  17. require('yargs').argv
  18. to get a parsed version of process.argv.
  19. */
  20. function singletonify (inst) {
  21. Object.keys(inst).forEach((key) => {
  22. if (key === 'argv') {
  23. Argv.__defineGetter__(key, inst.__lookupGetter__(key))
  24. } else {
  25. Argv[key] = typeof inst[key] === 'function' ? inst[key].bind(inst) : inst[key]
  26. }
  27. })
  28. }