Class DefaultHelpTextGenerator
- Namespace
- McMaster.Extensions.CommandLineUtils.HelpText
- Assembly
- McMaster.Extensions.CommandLineUtils.dll
A default implementation of help text generation.
public class DefaultHelpTextGenerator : IHelpTextGenerator
- Inheritance
-
objectDefaultHelpTextGenerator
- Implements
Constructors
DefaultHelpTextGenerator()
Initializes a new instance of DefaultHelpTextGenerator.
public DefaultHelpTextGenerator()
Fields
ColumnSeparatorLength
The number of spaces between columns.
protected const int ColumnSeparatorLength = 2
Field Value
Properties
IndentWriter
The hanging indent writer used for formatting indented and wrapped descriptions for options and arguments.
protected HangingIndentWriter? IndentWriter { get; set; }
Property Value
MaxLineLength
Override the console width disregarding any value from the executing environment.
public int? MaxLineLength { get; set; }
Property Value
- int?
Singleton
A singleton instance of DefaultHelpTextGenerator.
public static DefaultHelpTextGenerator Singleton { get; }
Property Value
SortCommandsByName
Determines if commands are ordered by name in generated help text
public bool SortCommandsByName { get; set; }
Property Value
Methods
Format(CommandOption)
Generates the template string in the format "-{Symbol}|-{Short}|--{Long} <{Value}>" for display in help text.
protected virtual string Format(CommandOption option)
Parameters
optionCommandOption
Returns
- string
The template string
Generate(CommandLineApplication, TextWriter)
Generate help text for the application.
public virtual void Generate(CommandLineApplication application, TextWriter output)
Parameters
applicationCommandLineApplicationoutputTextWriter
GenerateArguments(CommandLineApplication, TextWriter, IReadOnlyList<CommandArgument>, int)
Generate the lines that show information about arguments
protected virtual void GenerateArguments(CommandLineApplication application, TextWriter output, IReadOnlyList<CommandArgument> visibleArguments, int firstColumnWidth)
Parameters
applicationCommandLineApplicationThe app
outputTextWriterHelp text output
visibleArgumentsIReadOnlyList<CommandArgument>Arguments not hidden from help text
firstColumnWidthintThe width of the first column of commands, arguments, and options
GenerateBody(CommandLineApplication, TextWriter)
Generate detailed help information
protected virtual void GenerateBody(CommandLineApplication application, TextWriter output)
Parameters
applicationCommandLineApplicationThe application
outputTextWriterHelp text output
GenerateCommands(CommandLineApplication, TextWriter, IReadOnlyList<CommandLineApplication>, int)
Generate the lines that show information about subcommands
protected virtual void GenerateCommands(CommandLineApplication application, TextWriter output, IReadOnlyList<CommandLineApplication> visibleCommands, int firstColumnWidth)
Parameters
applicationCommandLineApplicationThe app
outputTextWriterHelp text output
visibleCommandsIReadOnlyList<CommandLineApplication>Commands not hidden from help text
firstColumnWidthintThe width of the first column of commands, arguments, and options
GenerateFooter(CommandLineApplication, TextWriter)
Generate the last lines of help text output
protected virtual void GenerateFooter(CommandLineApplication application, TextWriter output)
Parameters
applicationCommandLineApplicationThe app
outputTextWriterHelp text output
GenerateHeader(CommandLineApplication, TextWriter)
Generate the first few lines of help output text
protected virtual void GenerateHeader(CommandLineApplication application, TextWriter output)
Parameters
applicationCommandLineApplicationThe app
outputTextWriterHelp text output
GenerateOptions(CommandLineApplication, TextWriter, IReadOnlyList<CommandOption>, int)
Generate the lines that show information about options
protected virtual void GenerateOptions(CommandLineApplication application, TextWriter output, IReadOnlyList<CommandOption> visibleOptions, int firstColumnWidth)
Parameters
applicationCommandLineApplicationThe app
outputTextWriterHelp text output
visibleOptionsIReadOnlyList<CommandOption>Options not hidden from help text
firstColumnWidthintThe width of the first column of commands, arguments, and options
GenerateUsage(CommandLineApplication, TextWriter, IReadOnlyList<CommandArgument>, IReadOnlyList<CommandOption>, IReadOnlyList<CommandLineApplication>)
Generate the line that shows usage
protected virtual void GenerateUsage(CommandLineApplication application, TextWriter output, IReadOnlyList<CommandArgument> visibleArguments, IReadOnlyList<CommandOption> visibleOptions, IReadOnlyList<CommandLineApplication> visibleCommands)
Parameters
applicationCommandLineApplicationThe app
outputTextWriterHelp text output
visibleArgumentsIReadOnlyList<CommandArgument>Arguments not hidden from help text
visibleOptionsIReadOnlyList<CommandOption>Options not hidden from help text
visibleCommandsIReadOnlyList<CommandLineApplication>Commands not hidden from help text