6082594e1f2921731acb488c5e9d57585c81262c3c63ac5e2d1e021f3ec9b952ee66b618968e8342799bcc12067d222f99b9af6a3c2b977e271ee03dbe5f4c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. commist
  2. =======
  3. [![Build Status](https://travis-ci.com/mcollina/commist.svg?branch=master)](https://travis-ci.com/mcollina/commist)
  4. Build command line application with multiple commands the easy way.
  5. To be used with [minimist](http://npm.im/minimist).
  6. ```js
  7. var program = require('commist')()
  8. , minimist = require('minimist')
  9. , result
  10. result = program
  11. .register('abcd', function(args) {
  12. console.log('just do', args)
  13. })
  14. .register({ command: 'restore', equals: true }, function(args) {
  15. console.log('restore', args)
  16. })
  17. .register('args', function(args) {
  18. args = minimist(args)
  19. console.log('just do', args)
  20. })
  21. .register('abcde code', function(args) {
  22. console.log('doing something', args)
  23. })
  24. .register('another command', function(args) {
  25. console.log('anothering', args)
  26. })
  27. .parse(process.argv.splice(2))
  28. if (result) {
  29. console.log('no command called, args', result)
  30. }
  31. ```
  32. When calling _commist_ programs, you can abbreviate down to three char
  33. words. In the above example, these are valid commands:
  34. ```
  35. node example.js abc
  36. node example.js abc cod
  37. node example.js anot comm
  38. ```
  39. Moreover, little spelling mistakes are corrected too:
  40. ```
  41. node example.js abcs cod
  42. ```
  43. If you want that the command must be strict equals, you can register the
  44. command with the json configuration:
  45. ```js
  46. program.register({ command: 'restore', strict: true }, function(args) {
  47. console.log('restore', args)
  48. })
  49. ```
  50. Acknowledgements
  51. ----------------
  52. This project was kindly sponsored by [nearForm](http://nearform.com).
  53. License
  54. -------
  55. MIT