/// <summary> /// Provides Type-specific help content for the console, lists of all supported commands, plugins, local variables... /// </summary> /// <param name="option">Type of help content to show, if not specified it prompts the user</param> /// <param name="onlyThisConsole">if set to <c>true</c> [only this console].</param> /// <remarks> /// If help option is not specified, it will ask user for type of help should be displayed /// </remarks> /// <seealso cref="aceOperationSetExecutorBase" /> public void aceOperation_consoleHelp( [Description("Type of help content to show, if not specified it prompts the user")] aceCommandConsoleHelpOptions option = aceCommandConsoleHelpOptions.none, [Description("If true it will generate user manual only for this console")] Boolean onlyThisConsole = true ) { if (option == aceCommandConsoleHelpOptions.none) { option = aceTerminalInput.askForEnum <aceCommandConsoleHelpOptions>("Select Help option:", aceCommandConsoleHelpOptions.full); } if (onlyThisConsole) { var cst = commandTreeTools.BuildCommandTree(this, false); cst.ReportCommandTree(output, false, 0, option); helpContent = output.getLastLine(); } else { commandSetTree.ReportCommandTree(output, false, 0, option); helpContent = output.getLastLine(); } }
/// <summary> /// Reports the command tree. /// </summary> /// <param name="tree">The tree.</param> /// <param name="output">The output.</param> public static void ReportCommandTree(this commandTree tree, ITextRender output, Boolean paginate, Int32 lastPageLine = 0, aceCommandConsoleHelpOptions option = aceCommandConsoleHelpOptions.full) { output.AppendHeading(tree.name.ToUpper(), 1); output.AppendParagraph(tree.description); if (tree.helpLines.Any()) { output.AppendHeading("Description", 2); foreach (String ln in tree.helpLines) { output.AppendLine(ln); } } if (option.HasFlag(aceCommandConsoleHelpOptions.parameters)) { output.AppendHeading("Properties", 2); foreach (var pair in tree.properties) { output.AppendPair(pair.Value.Name, pair.Value.PropertyType.Name, true, ":"); } output.AppendHorizontalLine(); } if (option.HasFlag(aceCommandConsoleHelpOptions.plugins)) { output.AppendHeading("Plugins", 2); foreach (var pair in tree.plugins) { output.AppendPair(pair.Key.Trim('.'), pair.Value.GetType().Name, true, ":"); var methods = pair.Value.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public); if (Enumerable.Any <MethodInfo>(methods)) { List <String> lst = new List <string>(); foreach (MemberInfo mInfo in Enumerable.Where <MethodInfo>(methods, x => x.Name.StartsWith(aceMenuItemMeta.METHOD_PREFIX))) { lst.Add(pair.Key.add(mInfo.Name.removeStartsWith(aceMenuItemMeta.METHOD_PREFIX), ".").Trim('.')); } output.AppendList(lst); } } output.AppendHorizontalLine(); } if (option.HasFlag(aceCommandConsoleHelpOptions.modules)) { output.AppendHeading("Modules", 2); foreach (var pair in tree.modules) { output.AppendPair(pair.Value.Name, pair.Value.PropertyType.Name, true, ":"); } output.AppendHorizontalLine(); } //if (option.HasFlag(aceCommandConsoleHelpOptions.brief)) //{ // output.AppendHeading("Overview", 2); // foreach (var pair in tree.flatAccess) // { // output.AppendPair(pair.Value.path.Trim('.'), pair.Value.menuMeta.cmdParams.ToString(false, true, true), true, " "); // } // output.AppendHorizontalLine(); //} if (option.HasFlag(aceCommandConsoleHelpOptions.commands)) { foreach (commandTreeDescription node in tree) { node.ReportCommandNode(output, paginate, lastPageLine); } } }