cli.js 938 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Created by tivie
  3. */
  4. 'use strict';
  5. var yargs = require('yargs');
  6. yargs
  7. .version()
  8. .alias('v', 'version')
  9. .option('h', {
  10. alias: 'help',
  11. description: 'Show help'
  12. })
  13. .option('q', {
  14. alias: 'quiet',
  15. description: 'Quiet mode. Only print errors',
  16. type: 'boolean',
  17. default: false
  18. })
  19. .option('m', {
  20. alias: 'mute',
  21. description: 'Mute mode. Does not print anything',
  22. type: 'boolean',
  23. default: false
  24. })
  25. .usage('Usage: showdown <command> [options]')
  26. .demand(1, 'You must provide a valid command')
  27. .command('makehtml', 'Converts markdown into html')
  28. .example('showdown makehtml -i foo.md -o bar.html', 'Converts \'foo.md\' to \'bar.html\'')
  29. .wrap(yargs.terminalWidth());
  30. var argv = yargs.argv,
  31. command = argv._[0];
  32. if (command === 'makehtml') {
  33. require('./makehtml.cmd.js').run();
  34. } else {
  35. yargs.showHelp();
  36. }
  37. if (argv.help) {
  38. yargs.showHelp();
  39. }
  40. process.exit(0);