cli.js 688 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env node
  2. 'use strict';
  3. var argv = require('minimist')(process.argv.slice(2));
  4. var pkg = require('./package.json');
  5. var osxRelease = require('./');
  6. var input = argv._[0];
  7. function help() {
  8. console.log([
  9. '',
  10. ' ' + pkg.description,
  11. '',
  12. ' Usage',
  13. ' osx-release [release]',
  14. '',
  15. ' Example',
  16. ' osx-release',
  17. ' Mavericks 10.9',
  18. '',
  19. ' osx-release 14.0.0',
  20. ' Yosemite 10.10'
  21. ].join('\n'));
  22. }
  23. if (!input || argv.help) {
  24. help();
  25. return;
  26. }
  27. if (argv.version) {
  28. console.log(pkg.version);
  29. return;
  30. }
  31. var output = osxRelease(input);
  32. if (!output.name || !output.version) {
  33. process.exit(1);
  34. }
  35. console.log(output.name + ' ' + output.version);