public void ShowHelpScreen(IBaseWorker w, IList <string> remainArgs) { var commandLines = new SortedDictionary <string, List <TwoString> >(); var optionLines = new SortedDictionary <int, CmdFlagLines>(); // var writer = ColorifyEnabler.Colorify; // Console.Out; var command = w.ParsedCommand ?? w.RootCommand; tabStopCalculated = w.TabStop; const bool noBacktrace = false; w.Walk(command, commandsWatcherBuilder(w, commandLines, tabStopCalculated, noBacktrace), flagsWatcherBuilder(w, optionLines, tabStopCalculated, noBacktrace)); Painter.Setup(command, w, remainArgs); Painter.PrintPrologue(command, w, remainArgs); Painter.PrintPreface(command, w, remainArgs); Painter.PrintHeadLines(command, w, false, remainArgs); Painter.PrintUsages(command, w, remainArgs); Painter.PrintExamples(command, w, remainArgs); // ShowIt(command, commandLines, optionLines, writer, tabStop); Painter.PrintCommandsAndOptions(command, commandLines, optionLines, tabStopCalculated, false, w, remainArgs); Painter.PrintTailLines(command, w, remainArgs); Painter.PrintEpilogue(command, w, remainArgs); // writer.WriteLine(""); }
private void buildParentFlags(IBaseWorker w, ICommand?oo, IDictionary <int, CmdFlagLines> optionLines, int tabStop, bool noBacktrace) { // var oo = owner.Owner; while (oo != null && !ReferenceEquals(oo, oo.Owner)) { w.Walk(oo, (o, c, l) => true, flagsWatcherBuilder(w, optionLines, tabStop, noBacktrace) ); oo = oo.Owner; } }
public void ShowTreeDumpScreenForAllCommands(IBaseWorker w, IList <string> remainArgs) { w.log?.logDebug("dump tree"); // var writer = ColorifyEnabler.Colorify; // Console.Out; var commandLines = new SortedDictionary <string, List <TwoString> >(); var optionLines = new SortedDictionary <int, CmdFlagLines>(); var command = w.ParsedCommand ?? w.RootCommand; tabStopCalculated = w.TabStop; w.Walk(command, (owner, cmd, level) => { if (cmd.Hidden) { return(true); } var sb = new StringBuilder(" ".Repeat(1 + level)); if (!string.IsNullOrWhiteSpace(cmd.Short)) { sb.Append($"{cmd.Short}, "); } if (!string.IsNullOrWhiteSpace(cmd.Long)) { sb.Append($"{cmd.Long},"); } if (cmd.Aliases.Length > 0) { sb.AppendJoin(',', cmd.Aliases); } var sb2 = new StringBuilder(); if (!string.IsNullOrWhiteSpace(cmd.Description)) { sb2.Append(cmd.Description); } else if (!string.IsNullOrWhiteSpace(cmd.DescriptionLong)) { sb2.Append(cmd.DescriptionLong); } if (!commandLines.ContainsKey(cmd.Group)) { commandLines.TryAdd(cmd.Group, new List <TwoString>()); } if (sb.Length >= tabStopCalculated) { tabStopCalculated = sb.Length + 1; } commandLines[cmd.Group].Add(new TwoString { Part1 = sb.ToString(), Part2 = sb2.ToString() }); return(true); }, (owner, flag, level) => true); Painter.Setup(command, w, remainArgs); Painter.PrintPrologue(command, w, remainArgs); Painter.PrintPreface(command, w, remainArgs); Painter.PrintHeadLines(command, w, false, remainArgs); // ShowIt(w.ParsedCommand ?? w.RootCommand, commandLines, optionLines, writer, tabStop, true); Painter.PrintCommandsAndOptions(command, commandLines, optionLines, tabStopCalculated, true, w, remainArgs); // Painter.PrintTailLines(command, w, remainArgs); Painter.PrintEpilogue(command, w, remainArgs); // writer.WriteLine(""); }