public Command(string name, Action defaultAction, string helpMessage = null) { _identity = new CommandIdentity(name, helpMessage, GetType()); _default = defaultAction; _options = new Dictionary <char, Option>(); _keywords = new Dictionary <string, Keyword>(); }
void Help() { if (c != null) { CommandIdentity cmd = (from CommandIdentity cID in Karuta.commandIDs where cID.name == c select cID).First(); if (cmd != null) { Karuta.Write("\t" + cmd.name + "\t" + cmd.helpMessage); Karuta.Write("\tOptions:"); foreach (Option o in cmd.options) { Karuta.Write("\t\t -" + o.key + "\t" + o.usage); } Karuta.Write("\tKeywords:"); foreach (Keyword k in cmd.keywords) { Karuta.Write("\t\t " + k.keyword + "\t" + k.usage); } } else { Karuta.Write("No such command '" + c + "'"); } c = null; } else { Karuta.Write("The available commands are:"); foreach (CommandIdentity c in Karuta.commandIDs) { Karuta.Write("\t" + c.name + "\t" + c.helpMessage); //if (c.usageMessage != null) // Karuta.Write("\t\tUsage: " + c.usageMessage); } } }