설명 없음

constants.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env node
  2. 'use strict';
  3. var ArgumentParser = require('../lib/argparse').ArgumentParser;
  4. var parser = new ArgumentParser({
  5. version: '0.0.1',
  6. addHelp: true,
  7. description: 'Argparse examples: constant'
  8. });
  9. parser.addArgument(
  10. [ '-a'],
  11. {
  12. action: 'storeConst',
  13. dest: 'answer',
  14. help: 'store constant',
  15. constant: 42
  16. }
  17. );
  18. parser.addArgument(
  19. [ '--str' ],
  20. {
  21. action: 'appendConst',
  22. dest: 'types',
  23. help: 'append constant "str" to types',
  24. constant: 'str'
  25. }
  26. );
  27. parser.addArgument(
  28. [ '--int' ],
  29. {
  30. action: 'appendConst',
  31. dest: 'types',
  32. help: 'append constant "int" to types',
  33. constant: 'int'
  34. }
  35. );
  36. parser.addArgument(
  37. [ '--true' ],
  38. {
  39. action: 'storeTrue',
  40. help: 'store true constant'
  41. }
  42. );
  43. parser.addArgument(
  44. [ '--false' ],
  45. {
  46. action: 'storeFalse',
  47. help: 'store false constant'
  48. }
  49. );
  50. parser.printHelp();
  51. console.log('-----------');
  52. var args;
  53. args = parser.parseArgs('-a --str --int --true'.split(' '));
  54. console.dir(args);