private IDictionary <string, Command> CreateAllCommands() { var helpCommand = new HelpCommand(); var legacyHelpCommand = new LegacyHelpCommand(); var allCommandsByArray = new Command[] { helpCommand, legacyHelpCommand, new VersionCommand(), new LegacyVersionCommand(), new ChangelogCommand(), new LegacyChangelogCommand(), new ScanStartCommand(_basicMachines.Scan), new LegacyScanStartCommand(_basicMachines.Scan), new ScanShowCommand(_basicMachines.Scan), new LegacyScanShowCommand(_basicMachines.Scan), new ScanEndCommand(_basicMachines.Scan), new LegacyScanEndCommand(_basicMachines.Scan), }; helpCommand.HelpMessage = () => CommandsHelp.Create(allCommandsByArray); legacyHelpCommand.HelpMessage = () => CommandsHelp.Create(allCommandsByArray); return (allCommandsByArray .SelectMany(command => command.GetBodies().Select(body => new { Key = body, Value = command })) .ToDictionary(a => a.Key, a => a.Value)); }
public static void WriteCommandsHelp(bool includeValues = false, Filter?filter = null) { IEnumerable <Command> commands = LoadCommands(); CommandsHelp commandsHelp = CommandsHelp.Create(commands, OptionValueProviders.Providers, filter: filter); var writer = new ConsoleHelpWriter(new HelpWriterOptions(filter: filter)); writer.WriteCommands(commandsHelp); if (includeValues) { writer.WriteValues(commandsHelp.Values); } WriteLine(); WriteLine(GetFooterText()); }