nopt.js 644 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env node
  2. const nopt = require('../lib/nopt')
  3. const path = require('path')
  4. console.log('parsed', nopt({
  5. num: Number,
  6. bool: Boolean,
  7. help: Boolean,
  8. list: Array,
  9. 'num-list': [Number, Array],
  10. 'str-list': [String, Array],
  11. 'bool-list': [Boolean, Array],
  12. str: String,
  13. clear: Boolean,
  14. config: Boolean,
  15. length: Number,
  16. file: path,
  17. }, {
  18. s: ['--str', 'astring'],
  19. b: ['--bool'],
  20. nb: ['--no-bool'],
  21. tft: ['--bool-list', '--no-bool-list', '--bool-list', 'true'],
  22. '?': ['--help'],
  23. h: ['--help'],
  24. H: ['--help'],
  25. n: ['--num', '125'],
  26. c: ['--config'],
  27. l: ['--length'],
  28. f: ['--file'],
  29. }, process.argv, 2))