help.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var ArgumentParser, Base, Command, PackageJson, add_option_dict, log,
  4. __hasProp = {}.hasOwnProperty,
  5. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  6. Base = require('./base').Base;
  7. log = require('../log');
  8. ArgumentParser = require('argparse').ArgumentParser;
  9. add_option_dict = require('./argparse').add_option_dict;
  10. PackageJson = require('../package').PackageJson;
  11. exports.Command = Command = (function(_super) {
  12. __extends(Command, _super);
  13. function Command() {
  14. return Command.__super__.constructor.apply(this, arguments);
  15. }
  16. Command.prototype.add_subcommand_parser = function(scp) {
  17. var name, opts, sub;
  18. opts = {
  19. aliases: [],
  20. help: "display help"
  21. };
  22. name = "help";
  23. sub = scp.addParser(name, opts);
  24. sub.addArgument(["cmd"], {
  25. nargs: '?',
  26. help: "the subcommand you want help with"
  27. });
  28. return opts.aliases.concat([name]);
  29. };
  30. Command.prototype.run = function(cb) {
  31. var c, p;
  32. if ((c = this.argv.cmd) != null) {
  33. if ((p = this.parent.lookup_parser(c)) != null) {
  34. p.printHelp();
  35. } else {
  36. log.error("Command '" + c + "' isn't known");
  37. }
  38. } else {
  39. this.parent.ap.printHelp();
  40. }
  41. return cb(null);
  42. };
  43. return Command;
  44. })(Base);
  45. }).call(this);