Table of Contents

Class DefaultHelpTextGenerator

Namespace
McMaster.Extensions.CommandLineUtils.HelpText
Assembly
McMaster.Extensions.CommandLineUtils.dll

A default implementation of help text generation.

public class DefaultHelpTextGenerator : IHelpTextGenerator
Inheritance
object
DefaultHelpTextGenerator
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

int

Properties

IndentWriter

The hanging indent writer used for formatting indented and wrapped descriptions for options and arguments.

protected HangingIndentWriter? IndentWriter { get; set; }

Property Value

HangingIndentWriter

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

DefaultHelpTextGenerator

SortCommandsByName

Determines if commands are ordered by name in generated help text

public bool SortCommandsByName { get; set; }

Property Value

bool

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

option CommandOption

Returns

string

The template string

Generate(CommandLineApplication, TextWriter)

Generate help text for the application.

public virtual void Generate(CommandLineApplication application, TextWriter output)

Parameters

application CommandLineApplication
output TextWriter

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

application CommandLineApplication

The app

output TextWriter

Help text output

visibleArguments IReadOnlyList<CommandArgument>

Arguments not hidden from help text

firstColumnWidth int

The 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

application CommandLineApplication

The application

output TextWriter

Help 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

application CommandLineApplication

The app

output TextWriter

Help text output

visibleCommands IReadOnlyList<CommandLineApplication>

Commands not hidden from help text

firstColumnWidth int

The 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

application CommandLineApplication

The app

output TextWriter

Help text output

GenerateHeader(CommandLineApplication, TextWriter)

Generate the first few lines of help output text

protected virtual void GenerateHeader(CommandLineApplication application, TextWriter output)

Parameters

application CommandLineApplication

The app

output TextWriter

Help 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

application CommandLineApplication

The app

output TextWriter

Help text output

visibleOptions IReadOnlyList<CommandOption>

Options not hidden from help text

firstColumnWidth int

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

protected virtual void GenerateUsage(CommandLineApplication application, TextWriter output, IReadOnlyList<CommandArgument> visibleArguments, IReadOnlyList<CommandOption> visibleOptions, IReadOnlyList<CommandLineApplication> visibleCommands)

Parameters

application CommandLineApplication

The app

output TextWriter

Help text output

visibleArguments IReadOnlyList<CommandArgument>

Arguments not hidden from help text

visibleOptions IReadOnlyList<CommandOption>

Options not hidden from help text

visibleCommands IReadOnlyList<CommandLineApplication>

Commands not hidden from help text