atomic-cli.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/env node
  2. "use strict";
  3. // https://github.com/yeoman/update-notifier
  4. // https://github.com/tj/commander.js
  5. var path = require("path");
  6. var program = require('commander');
  7. var cli = require("atomic-cli")
  8. program
  9. .version('0.0.1')
  10. .parse(process.argv);
  11. // new project command
  12. program
  13. .command('new <folder>')
  14. .description('creates a new project in the specified folder')
  15. .action(function(folder){
  16. cli.newProject(folder)
  17. .then(function () {
  18. console.log("New Atomic project created in " + path.resolve(folder));
  19. })
  20. .catch(function (error) {
  21. console.error("Error: Could not create " + path.resolve(folder));
  22. process.exit(1);
  23. });
  24. });
  25. program
  26. .command('add <platform>')
  27. .description('adds a platform to the project')
  28. .action(function(platform){
  29. cli.addPlatform(platform)
  30. .then(function () {
  31. })
  32. .catch(function (error) {
  33. process.exit(1);
  34. });
  35. });
  36. program
  37. .command('run <platform> [no-build]')
  38. .description('runs the project on a specified platform')
  39. .action(function(platform){
  40. cli.run(platform)
  41. .then(function () {
  42. })
  43. .catch(function (error) {
  44. process.exit(1);
  45. });
  46. });
  47. program.parse(process.argv);
  48. if (!program.args.length) program.help();