public void ShowCommandHelp(string cmd) { CommandAttribute attr = CommandRegistry.GetCommandAttribute(cmd); if (attr == null) { Console.WriteLine("Unknown command: " + cmd); Console.WriteLine(); ShowHelp(); return; } ShowCommandHelp(attr, ""); Console.WriteLine("Usage: " + cmd + " " + attr.Args); Console.WriteLine(); Console.WriteLine("Options:"); Type commandType = CommandRegistry.GetCommandType(cmd); foreach (MemberInfo mi in commandType.GetMembers()) { if (mi.MemberType != MemberTypes.Field) { continue; } OptionAttribute[] attribs = mi.GetCustomAttributes(typeof(OptionAttribute), true) as OptionAttribute[]; if (attribs == null || attribs.Length == 0) { continue; } foreach (OptionAttribute attrib in attribs) { Type fieldType = ((FieldInfo)mi).FieldType; if (!String.IsNullOrEmpty(attrib.AlternateForm)) { string altform = " /" + attrib.AlternateForm + ""; if (fieldType != typeof(bool)) { altform += ":ARG"; } Console.Write(altform.PadRight(20)); } Console.Write("\t" + attrib.ShortDescription); if (!String.IsNullOrEmpty(attrib.LongForm)) { Console.Write(" (also /" + attrib.LongForm); if (fieldType != typeof(bool)) { Console.Write(":ARG"); } Console.Write(")"); } Console.WriteLine(); } } Console.WriteLine(); }