Class DefaultHelpTextGenerator
A default implementation of help text generation.
Inheritance
Implements
Namespace: McMaster.Extensions.CommandLineUtils.HelpText
Assembly: McMaster.Extensions.CommandLineUtils.dll
Syntax
public class DefaultHelpTextGenerator : IHelpTextGenerator
Constructors
| Improve this Doc View SourceDefaultHelpTextGenerator()
Initializes a new instance of DefaultHelpTextGenerator.
Declaration
public DefaultHelpTextGenerator()
Fields
| Improve this Doc View SourceColumnSeparatorLength
The number of spaces between columns.
Declaration
protected const int ColumnSeparatorLength = 2
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
| Improve this Doc View SourceIndentWriter
The hanging indent writer used for formatting indented and wrapped descriptions for options and arguments.
Declaration
protected HangingIndentWriter IndentWriter { get; set; }
Property Value
Type | Description |
---|---|
HangingIndentWriter |
MaxLineLength
Override the console width disregarding any value from the executing environment.
Declaration
public int? MaxLineLength { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
Singleton
A singleton instance of DefaultHelpTextGenerator.
Declaration
public static DefaultHelpTextGenerator Singleton { get; }
Property Value
Type | Description |
---|---|
DefaultHelpTextGenerator |
SortCommandsByName
Determines if commands are ordered by name in generated help text
Declaration
public bool SortCommandsByName { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceFormat(CommandOption)
Generates the template string in the format "-{Symbol}|-{Short}|--{Long} <{Value}>" for display in help text.
Declaration
protected virtual string Format(CommandOption option)
Parameters
Type | Name | Description |
---|---|---|
CommandOption | option |
Returns
Type | Description |
---|---|
System.String | The template string |
Generate(CommandLineApplication, TextWriter)
Generate help text for the application.
Declaration
public virtual void Generate(CommandLineApplication application, TextWriter output)
Parameters
Type | Name | Description |
---|---|---|
CommandLineApplication | application | |
System.IO.TextWriter | output |
GenerateArguments(CommandLineApplication, TextWriter, IReadOnlyList<CommandArgument>, Int32)
Generate the lines that show information about arguments
Declaration
protected virtual void GenerateArguments(CommandLineApplication application, TextWriter output, IReadOnlyList<CommandArgument> visibleArguments, int firstColumnWidth)
Parameters
Type | Name | Description |
---|---|---|
CommandLineApplication | application | The app |
System.IO.TextWriter | output | Help text output |
System.Collections.Generic.IReadOnlyList<CommandArgument> | visibleArguments | Arguments not hidden from help text |
System.Int32 | firstColumnWidth | The width of the first column of commands, arguments, and options |
GenerateBody(CommandLineApplication, TextWriter)
Generate detailed help information
Declaration
protected virtual void GenerateBody(CommandLineApplication application, TextWriter output)
Parameters
Type | Name | Description |
---|---|---|
CommandLineApplication | application | The application |
System.IO.TextWriter | output | Help text output |
GenerateCommands(CommandLineApplication, TextWriter, IReadOnlyList<CommandLineApplication>, Int32)
Generate the lines that show information about subcommands
Declaration
protected virtual void GenerateCommands(CommandLineApplication application, TextWriter output, IReadOnlyList<CommandLineApplication> visibleCommands, int firstColumnWidth)
Parameters
Type | Name | Description |
---|---|---|
CommandLineApplication | application | The app |
System.IO.TextWriter | output | Help text output |
System.Collections.Generic.IReadOnlyList<CommandLineApplication> | visibleCommands | Commands not hidden from help text |
System.Int32 | firstColumnWidth | The width of the first column of commands, arguments, and options |
GenerateFooter(CommandLineApplication, TextWriter)
Generate the last lines of help text output
Declaration
protected virtual void GenerateFooter(CommandLineApplication application, TextWriter output)
Parameters
Type | Name | Description |
---|---|---|
CommandLineApplication | application | The app |
System.IO.TextWriter | output | Help text output |
GenerateHeader(CommandLineApplication, TextWriter)
Generate the first few lines of help output text
Declaration
protected virtual void GenerateHeader(CommandLineApplication application, TextWriter output)
Parameters
Type | Name | Description |
---|---|---|
CommandLineApplication | application | The app |
System.IO.TextWriter | output | Help text output |
GenerateOptions(CommandLineApplication, TextWriter, IReadOnlyList<CommandOption>, Int32)
Generate the lines that show information about options
Declaration
protected virtual void GenerateOptions(CommandLineApplication application, TextWriter output, IReadOnlyList<CommandOption> visibleOptions, int firstColumnWidth)
Parameters
Type | Name | Description |
---|---|---|
CommandLineApplication | application | The app |
System.IO.TextWriter | output | Help text output |
System.Collections.Generic.IReadOnlyList<CommandOption> | visibleOptions | Options not hidden from help text |
System.Int32 | firstColumnWidth | The 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
Declaration
protected virtual void GenerateUsage(CommandLineApplication application, TextWriter output, IReadOnlyList<CommandArgument> visibleArguments, IReadOnlyList<CommandOption> visibleOptions, IReadOnlyList<CommandLineApplication> visibleCommands)
Parameters
Type | Name | Description |
---|---|---|
CommandLineApplication | application | The app |
System.IO.TextWriter | output | Help text output |
System.Collections.Generic.IReadOnlyList<CommandArgument> | visibleArguments | Arguments not hidden from help text |
System.Collections.Generic.IReadOnlyList<CommandOption> | visibleOptions | Options not hidden from help text |
System.Collections.Generic.IReadOnlyList<CommandLineApplication> | visibleCommands | Commands not hidden from help text |