зеркало из https://github.com/microsoft/TACO.git
general usage, resources commenting
This commit is contained in:
Родитель
1a84577a10
Коммит
5abe0b3f6c
|
@ -51,10 +51,18 @@ class Help implements commands.ICommand {
|
|||
}
|
||||
|
||||
/**
|
||||
* prints out general usage of all support TACO commands
|
||||
* prints out general usage of all support TACO commands, iterates through commands and their descriptions
|
||||
*/
|
||||
public printGeneralUsage(): void {
|
||||
logger.logLine("\nGeneral Usage", level.Normal);
|
||||
logger.logLine(resourcesManager.getString("command.help.usage.synopsis") + "\n", level.NormalBold);
|
||||
logger.logLine(this.indent + resourcesManager.getString("command.help.taco.usage") + "\n", level.Success);
|
||||
|
||||
var nameValuePairs: tacoUtility.Commands.INameDescription[] = new Array();
|
||||
for (var i in commandsFactory.Listings) {
|
||||
nameValuePairs.push({ name: i, description: commandsFactory.Listings[i].description});
|
||||
}
|
||||
|
||||
this.printCommandTable(nameValuePairs, this.indent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,17 +71,17 @@ class Help implements commands.ICommand {
|
|||
*/
|
||||
public printCommandUsage(command: string): void {
|
||||
if (!commandsFactory.Listings || !commandsFactory.Listings[command]) {
|
||||
logger.logErrorLine("command.help.badcomand");
|
||||
logger.logErrorLine(resourcesManager.getString("command.help.badcomand", "'" + command + "'") + "\n");
|
||||
this.printGeneralUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
var list: tacoUtility.Commands.ICommandInfo = commandsFactory.Listings[command];
|
||||
logger.logLine("Synopsis\n", level.NormalBold);
|
||||
logger.logLine(resourcesManager.getString("command.help.usage.synopsis") + "\n", level.NormalBold);
|
||||
logger.logLine(this.indent + this.tacoString + " " + command + " " + list.synopsis + "\n", level.Success);
|
||||
logger.logLine(this.getString(list.description) + "\n", level.NormalBold);
|
||||
this.printCommandTable(list.args, this.indent);
|
||||
logger.logLine("\n" + this.indent + "Options:\n", level.NormalBold);
|
||||
logger.logLine("\n" + this.indent + resourcesManager.getString("command.help.usage.options") + "\n", level.NormalBold);
|
||||
this.printCommandTable(list.options, this.indent + this.indent);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ class Taco {
|
|||
command = commandsFactory.getTask("help", process.argv);
|
||||
}
|
||||
|
||||
// if no command found that can handle these args, route directly to Cordova
|
||||
// if no command found that can handle these args, route args directly to Cordova
|
||||
if (!command) {
|
||||
cordova.cli(process.argv.splice(1));
|
||||
cordova.cli(process.argv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,5 +9,16 @@
|
|||
"[command.create.options.copy]": "Use custom www assets instead using a template.",
|
||||
"[command.create.options.linkto]": "Symlink to custom www assets without creating a copy.",
|
||||
"[command.help.description]": "Get help for a command",
|
||||
"command.help.badcomand": "%s is not a valid command"
|
||||
"command.help.usage.synopsis": "Synopsis",
|
||||
"_command.help.usage.synopsis.comment": "synopsis header when user types 'taco help'",
|
||||
"command.help.usage.options": "Options:",
|
||||
"_command.help.usage.options.comment": "options header when user types 'taco help'",
|
||||
"command.help.badcomand": "{0} is not a valid command",
|
||||
"_command.help.badcomand.comment": "message shown when user enters invalid taco cli command",
|
||||
"command.help.taco.usage": "taco command [options]",
|
||||
"_command.help.taco.usage.comment": "CLI pattern shown in taco help",
|
||||
"taco-utils.exception.listingfile": "Cannot find command listing file",
|
||||
"_taco-utils.exception.listingfile.comment": "error finding commands.json, shouldn't happen",
|
||||
"taco-utils.exception.missingcommand": "Cannot find command module",
|
||||
"_taco-utils.exception.missingcommand.comment": "can find commands.json, but cannot find module referenced i.e. create.js, shouldn't happen"
|
||||
}
|
|
@ -126,7 +126,7 @@ module TacoUtility {
|
|||
public static init(commandsInfoPath: string) {
|
||||
commandsInfoPath = path.resolve(commandsInfoPath);
|
||||
if (!fs.existsSync(commandsInfoPath)) {
|
||||
throw new Error("Cannot find commands listing file");
|
||||
throw new Error(ResourcesManager.getString("taco-utils.exception.listingfile"));
|
||||
}
|
||||
|
||||
CommandFactory.Listings = require(commandsInfoPath);
|
||||
|
@ -137,7 +137,7 @@ module TacoUtility {
|
|||
*/
|
||||
public static getTask(name: string, inputArgs: string[]): ICommand {
|
||||
if (!name || !CommandFactory.Listings) {
|
||||
throw new Error("Cannot find command listing file");
|
||||
throw new Error(ResourcesManager.getString("taco-utils.exception.listingfile"));
|
||||
}
|
||||
|
||||
var moduleInfo: ICommandInfo = CommandFactory.Listings[name];
|
||||
|
@ -147,7 +147,7 @@ module TacoUtility {
|
|||
|
||||
var modulePath = path.resolve(moduleInfo.modulePath);
|
||||
if (!fs.existsSync(modulePath + ".js")) {
|
||||
throw new Error("Cannot find command module");
|
||||
throw new Error(ResourcesManager.getString("taco-utils.exception.missingcommand"));
|
||||
}
|
||||
|
||||
var commandMod: any = require(modulePath);
|
||||
|
|
Загрузка…
Ссылка в новой задаче