example.js 658 B

123456789101112131415161718192021222324252627
  1. var program = require('./')()
  2. var minimist = require('minimist')
  3. var result
  4. result = program
  5. .register('abcd', function (args) {
  6. console.log('just do', args)
  7. })
  8. .register({ command: 'restore', strict: true }, function (args) {
  9. console.log('restore', args)
  10. })
  11. .register('args', function (args) {
  12. args = minimist(args)
  13. console.log('just do', args)
  14. })
  15. .register('abcde code', function (args) {
  16. console.log('doing something', args)
  17. })
  18. .register('another command', function (args) {
  19. console.log('anothering', args)
  20. })
  21. .parse(process.argv.splice(2))
  22. if (result) {
  23. console.log('no command called, args', result)
  24. }