UNPKG

mobile-cli-lib

Version:
41 lines (40 loc) 1.6 kB
"use strict"; var os_1 = require("os"); var Future = require("fibers/future"); var HelpCommand = (function () { function HelpCommand($logger, $injector, $htmlHelpService, $staticConfig, $options) { this.$logger = $logger; this.$injector = $injector; this.$htmlHelpService = $htmlHelpService; this.$staticConfig = $staticConfig; this.$options = $options; this.enableHooks = false; this.allowedParameters = []; } HelpCommand.prototype.canExecute = function (args) { return Future.fromResult(true); }; HelpCommand.prototype.execute = function (args) { var _this = this; return (function () { var topic = (args[0] || "").toLowerCase(); var hierarchicalCommand = _this.$injector.buildHierarchicalCommand(args[0], _.tail(args)); if (hierarchicalCommand) { topic = hierarchicalCommand.commandName; } if (_this.$options.help) { var help = _this.$htmlHelpService.getCommandLineHelpForCommand(topic).wait(); if (_this.$staticConfig.FULL_CLIENT_NAME) { _this.$logger.info(_this.$staticConfig.FULL_CLIENT_NAME.green.bold + os_1.EOL); } _this.$logger.printMarkdown(help); } else { _this.$htmlHelpService.openHelpForCommandInBrowser(topic).wait(); } }).future()(); }; return HelpCommand; }()); exports.HelpCommand = HelpCommand; $injector.registerCommand(["help", "/?"], HelpCommand);