I changed the example CustomCommands.cs's "Help" command to provide a list of all available commands, their description, and their usage when "Help" is entered without any other args. Here is the new help method:
private static string Help(params string[] args)
{
// if we got it wrong, get help about the HELP command
if (args.Length == 0)
{
String commands = "";
List<KeyValuePair<string, ConsoleCommand>> list = ConsoleCommandsDatabase.database.ToList();
foreach (KeyValuePair<string, ConsoleCommand> pair in list)
{
commands += string.Format (
"{0}: {1} Usage: {2}\n", pair.Key,
pair.Value.description,
pair.Value.usage);
}
return Help("HELP") + "\nList of available commands:\n" + commands;
}
// if we got it right, get help about the given command
string commandToGetHelpAbout = args[0].ToUpper();
ConsoleCommand found;
if(ConsoleCommandsDatabase.TryGetCommand(commandToGetHelpAbout, out found))
return string.Format("Help information about {0}\n\r\tDescription: {1}\n\r\tUsage: {2}", commandToGetHelpAbout, found.description, found.usage);
else
return string.Format("Cannot find help information about {0}. Are you sure it is a valid command?", commandToGetHelpAbout);
}
I changed the example CustomCommands.cs's "Help" command to provide a list of all available commands, their description, and their usage when "Help" is entered without any other args. Here is the new help method: