private static void WriteManual(bool includeValues = false, Filter?filter = null) { IEnumerable <Command> commands = LoadCommands(); var writer = new ConsoleHelpWriter(new HelpWriterOptions(filter: filter)); IEnumerable <CommandHelp> commandHelps = commands.Select(f => CommandHelp.Create(f, filter: filter)) .Where(f => f.Arguments.Any() || f.Options.Any()) .ToImmutableArray(); ImmutableArray <CommandItem> commandItems = HelpProvider.GetCommandItems(commandHelps.Select(f => f.Command)); ImmutableArray <OptionValueList> values = ImmutableArray <OptionValueList> .Empty; if (commandItems.Any()) { values = HelpProvider.GetAllowedValues(commandHelps.SelectMany(f => f.Command.Options), OptionValueProviders.Providers, filter); var commandsHelp = new CommandsHelp(commandItems, values); writer.WriteCommands(commandsHelp); foreach (CommandHelp commandHelp in commandHelps) { WriteSeparator(); WriteLine(); WriteLine($"Command: {commandHelp.Name}"); WriteLine(); string description = commandHelp.Description; if (!string.IsNullOrEmpty(description)) { WriteLine(description); WriteLine(); } writer.WriteCommand(commandHelp); } if (includeValues) { WriteSeparator(); } } else { WriteLine(); WriteLine("No command found"); if (includeValues) { values = HelpProvider.GetAllowedValues(commands.Select(f => CommandHelp.Create(f)).SelectMany(f => f.Command.Options), OptionValueProviders.Providers, filter); } } if (includeValues) { writer.WriteValues(values); }
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()); }