public static CommandResult CommandHelp(string command, CommandLineProtoRegistry commands) { if (commands.TryGetValue(command, out CommandLineProto cd)) { CommandResult result = new CommandResult(); result.AddMessage($"{command}\t{cd.Usage.Description}"); result.AddMessage(); result.AddMessage($"{cd.Syntax}"); if (cd.Count > 0) { result.AddMessage(); result.AddMessage("Where:"); result.AddMessage(); foreach (var arg in cd.OfType <CommandArgProto>()) { result.AddMessage($"{arg.Name}\t{arg.Description}"); } } return(result); } else { return(new CommandResult(false, "'{command}' is not a command")); } }
public static CommandResult GeneralHelp(CommandLineProtoRegistry commands) { CommandResult result = new CommandResult(); result.AddMessage($"{ProgramInfo.GetProgramName()} {ProgramInfo.GetProgramVersion()}"); result.AddMessage(); var description = ProgramInfo.GetProgramDescription(); if (!String.IsNullOrEmpty(description)) { result.AddMessage(description); result.AddMessage(); } var names = from name in commands.Keys orderby name select name; foreach (var name in names) { string commandDescription = commands[name].Usage.Description; result.AddMessage($"{name}\t{commandDescription}"); } return(result); }