Class CommandLineApplication
Describes a set of command line arguments, options, and execution behavior. CommandLineApplication can be nested to support subcommands.
Implements
Namespace: McMaster.Extensions.CommandLineUtils
Assembly: McMaster.Extensions.CommandLineUtils.dll
Syntax
public class CommandLineApplication : IServiceProvider, IDisposable
Constructors
| Improve this Doc View SourceCommandLineApplication()
Initializes a new instance of CommandLineApplication.
Declaration
public CommandLineApplication()
CommandLineApplication(IHelpTextGenerator, IConsole, String)
Initializes a new instance of CommandLineApplication.
Declaration
public CommandLineApplication(IHelpTextGenerator helpTextGenerator, IConsole console, string workingDirectory)
Parameters
| Type | Name | Description |
|---|---|---|
| IHelpTextGenerator | helpTextGenerator | The help text generator to use. |
| IConsole | console | The console implementation to use. |
| System.String | workingDirectory | The current working directory. |
CommandLineApplication(IConsole)
Initializes a new instance of CommandLineApplication.
Declaration
public CommandLineApplication(IConsole console)
Parameters
| Type | Name | Description |
|---|---|---|
| IConsole | console | The console implementation to use. |
CommandLineApplication(IConsole, String)
Initializes a new instance of CommandLineApplication.
Declaration
public CommandLineApplication(IConsole console, string workingDirectory)
Parameters
| Type | Name | Description |
|---|---|---|
| IConsole | console | The console implementation to use. |
| System.String | workingDirectory | The current working directory. |
Properties
| Improve this Doc View SourceAllowArgumentSeparator
Determines if '--' can be used to separate known arguments and options from additional content passed to RemainingArguments.
Declaration
public bool AllowArgumentSeparator { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Arguments
Required command-line arguments.
Declaration
public List<CommandArgument> Arguments { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<CommandArgument> |
ClusterOptions
One or more options of NoValue, followed by at most one option that takes values, should be accepted when grouped behind one '-' delimiter.
When true, the following are equivalent.
-abcXyellow
-abcX=yellow
-abcX:yellow
-abc -X=yellow
-ab -cX=yellow
-a -b -c -Xyellow
-a -b -c -X yellow
-a -b -c -X=yellow
-a -b -c -X:yellow
This defaults to true unless an option with a short name of two or more characters is added.
Declaration
public bool ClusterOptions { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
| Improve this Doc View SourceCommands
Subcommands.
Declaration
public List<CommandLineApplication> Commands { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<CommandLineApplication> |
Conventions
Gets a builder that can be used to apply conventions to
Declaration
public IConventionBuilder Conventions { get; }
Property Value
| Type | Description |
|---|---|
| IConventionBuilder |
Description
A description of the command.
Declaration
public string Description { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Error
The writer used to display generated error messages.
Declaration
public TextWriter Error { get; set; }
Property Value
| Type | Description |
|---|---|
| System.IO.TextWriter |
ExtendedHelpText
Additional text that appears at the bottom of generated help text.
Declaration
public string ExtendedHelpText { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
FullName
The full name of the command to show in the help text.
Declaration
public string FullName { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
HelpTextGenerator
The help text generator to use.
Declaration
public IHelpTextGenerator HelpTextGenerator { get; set; }
Property Value
| Type | Description |
|---|---|
| IHelpTextGenerator |
IsShowingInformation
True when OptionHelp or OptionVersion was matched.
Declaration
public bool IsShowingInformation { get; protected set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
LongVersionGetter
The long-form of the version to display in generated help text.
Declaration
public Func<string> LongVersionGetter { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Func<System.String> |
MakeSuggestionsInErrorMessage
When an invalid argument is given, make suggestions in the error message about similar, valid commands or options.
$ git pshu Specify --help for a list of available options and commands Unrecognized command or argument 'pshu'
Did you mean this? push
Declaration
public bool MakeSuggestionsInErrorMessage { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Name
The short name of the command. When this is a subcommand, it is the name of the word used to invoke the subcommand.
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Names
All names by which the command can be referenced. This includes Name and an aliases added in AddName(String).
Declaration
public IEnumerable<string> Names { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<System.String> |
OptionHelp
The option used to determine if help text should be displayed. This is set by calling HelpOption(String).
Declaration
public CommandOption OptionHelp { get; }
Property Value
| Type | Description |
|---|---|
| CommandOption |
OptionNameValueSeparators
Characters used to separate the option name from the value.
By default, allowed separators are ' ' (space), :, and =
Declaration
public char[] OptionNameValueSeparators { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Char[] |
Remarks
Space actually implies multiple spaces due to the way most operating system shells parse command line arguments before starting a new process.
Examples
Given --name=value, = is the separator.
| Improve this Doc View SourceOptions
Available command-line options on this command. Use GetOptions() to get all available options, which may include inherited options.
Declaration
public List<CommandOption> Options { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<CommandOption> |
OptionsComparison
The way arguments and options are matched.
Declaration
public StringComparison OptionsComparison { get; set; }
Property Value
| Type | Description |
|---|---|
| System.StringComparison |
OptionVersion
The options used to determine if the command version should be displayed. This is set by calling VersionOption(String, Func<String>, Func<String>).
Declaration
public CommandOption OptionVersion { get; }
Property Value
| Type | Description |
|---|---|
| CommandOption |
Out
The writer used to display generated help text.
Declaration
public TextWriter Out { get; set; }
Property Value
| Type | Description |
|---|---|
| System.IO.TextWriter |
Parent
Defaults to null. A link to the parent command if this is instance is a subcommand.
Declaration
public CommandLineApplication Parent { get; set; }
Property Value
| Type | Description |
|---|---|
| CommandLineApplication |
RemainingArguments
When initialized when UnrecognizedArgumentHandling is StopParsingAndCollect, this will contain any unrecognized arguments.
Declaration
public List<string> RemainingArguments { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.String> |
ResponseFileHandling
When enabled, the parser will treat any arguments beginning with '@' as a file path to a response file. A response file contains additional arguments that will be treated as if they were passed in on the command line.
Defaults to Disabled.
Nested response false are not supported.
Declaration
public ResponseFileHandling ResponseFileHandling { get; set; }
Property Value
| Type | Description |
|---|---|
| ResponseFileHandling |
ShortVersionGetter
The short-form of the version to display in generated help text.
Declaration
public Func<string> ShortVersionGetter { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Func<System.String> |
ShowInHelpText
Determines if this command appears in generated help text.
Declaration
public bool ShowInHelpText { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
UnrecognizedArgumentHandling
Configures what the parser should do when it runs into an unexpected argument.
Declaration
public UnrecognizedArgumentHandling UnrecognizedArgumentHandling { get; set; }
Property Value
| Type | Description |
|---|---|
| UnrecognizedArgumentHandling |
UsePagerForHelpText
Whether a Pager should be used to display help text.
Declaration
public bool UsePagerForHelpText { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ValidationErrorHandler
The action to call when the command executes, but there was an error validation options or arguments. The action can return a new validation result.
Declaration
public Func<ValidationResult, int> ValidationErrorHandler { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Func<System.ComponentModel.DataAnnotations.ValidationResult, System.Int32> |
Validators
A collection of validators that execute before invoking OnExecute(Func<Int32>). When validation fails, ValidationErrorHandler is invoked.
Declaration
public ICollection<ICommandValidator> Validators { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.ICollection<ICommandValidator> |
ValueParsers
Gets the default value parser provider.
The value parsers control how argument values are converted from strings to other types. Additional value parsers can be added so that domain specific types can converted. In-built value parsers can also be replaced for precise control of all type conversion.
Declaration
public ValueParserProvider ValueParsers { get; }
Property Value
| Type | Description |
|---|---|
| ValueParserProvider |
WorkingDirectory
Defines the working directory of the application. Defaults to System.IO.Directory.GetCurrentDirectory.
This will be used as the base path for opening response files when ResponseFileHandling is true.
Declaration
public string WorkingDirectory { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
| Improve this Doc View SourceAddName(String)
Add another name for the command.
Additional names can be shorter, longer, or alternative names by which a command may be invoked on the command line.
Declaration
public void AddName(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. Must not be null or empty. |
AddSubcommand(CommandLineApplication)
Add a subcommand
Declaration
public void AddSubcommand(CommandLineApplication subcommand)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandLineApplication | subcommand |
Argument(String, String, Action<CommandArgument>, Boolean)
Adds a command line argument.
Declaration
public CommandArgument Argument(string name, string description, Action<CommandArgument> configuration, bool multipleValues = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | |
| System.String | description | |
| System.Action<CommandArgument> | configuration | |
| System.Boolean | multipleValues |
Returns
| Type | Description |
|---|---|
| CommandArgument |
Argument(String, String, Boolean)
Adds a command line argument
Declaration
public CommandArgument Argument(string name, string description, bool multipleValues = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | |
| System.String | description | |
| System.Boolean | multipleValues |
Returns
| Type | Description |
|---|---|
| CommandArgument |
Argument<T>(String, String, Action<CommandArgument>, Boolean)
Adds a command line argument with values that should be parsable into T.
Declaration
public CommandArgument<T> Argument<T>(string name, string description, Action<CommandArgument> configuration, bool multipleValues = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | |
| System.String | description | |
| System.Action<CommandArgument> | configuration | |
| System.Boolean | multipleValues |
Returns
| Type | Description |
|---|---|
| CommandArgument<T> |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the values on the option |
Command(String, Action<CommandLineApplication>)
Adds a subcommand.
Declaration
public CommandLineApplication Command(string name, Action<CommandLineApplication> configuration)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The word used to invoke the subcommand. |
| System.Action<CommandLineApplication> | configuration | A callback to configure the created subcommand. |
Returns
| Type | Description |
|---|---|
| CommandLineApplication |
Command<TModel>(String, Action<CommandLineApplication<TModel>>)
Adds a subcommand with model of type TModel.
Declaration
public CommandLineApplication<TModel> Command<TModel>(string name, Action<CommandLineApplication<TModel>> configuration)
where TModel : class
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The word used to invoke the subcommand. |
| System.Action<CommandLineApplication<TModel>> | configuration | A callback used to configure the subcommand object. |
Returns
| Type | Description |
|---|---|
| CommandLineApplication<TModel> |
Type Parameters
| Name | Description |
|---|---|
| TModel | The model type of the subcommand. |
Dispose()
Declaration
public virtual void Dispose()
Execute(String[])
Parses an array of strings using Parse(String[]).
If OptionHelp was matched, the generated help text is displayed in command line output.
If OptionVersion was matched, the generated version info is displayed in command line output.
If there were any validation errors produced from GetValidationResult(), ValidationErrorHandler is invoked.
If the parse result matches this command, the function passed to OnExecute(Func<Int32>) or OnExecuteAsync(Func<CancellationToken, Task<Int32>>) will be invoked.
Declaration
public int Execute(params string[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String[] | args |
Returns
| Type | Description |
|---|---|
| System.Int32 | The return code from the function passed to OnExecute(Func<Int32>) or OnExecuteAsync(Func<CancellationToken, Task<Int32>>). |
Execute<TApp>(CommandLineContext)
Creates an instance of TApp, matching Arguments
to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
Declaration
public static int Execute<TApp>(CommandLineContext context)
where TApp : class
Parameters
| Type | Name | Description |
|---|---|---|
| CommandLineContext | context | The execution context. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The process exit code |
Type Parameters
| Name | Description |
|---|---|
| TApp | A type that should be bound to the arguments. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when attributes are incorrectly configured. |
See Also
| Improve this Doc View SourceExecute<TApp>(IConsole, String[])
Creates an instance of TApp, matching args
to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
Declaration
public static int Execute<TApp>(IConsole console, params string[] args)
where TApp : class
Parameters
| Type | Name | Description |
|---|---|---|
| IConsole | console | The console to use |
| System.String[] | args | The arguments |
Returns
| Type | Description |
|---|---|
| System.Int32 | The process exit code |
Type Parameters
| Name | Description |
|---|---|
| TApp | A type that should be bound to the arguments. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when attributes are incorrectly configured. |
See Also
| Improve this Doc View SourceExecute<TApp>(String[])
Creates an instance of TApp, matching args
to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
Declaration
public static int Execute<TApp>(params string[] args)
where TApp : class
Parameters
| Type | Name | Description |
|---|---|---|
| System.String[] | args | The arguments |
Returns
| Type | Description |
|---|---|
| System.Int32 | The process exit code |
Type Parameters
| Name | Description |
|---|---|
| TApp | A type that should be bound to the arguments. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when attributes are incorrectly configured. |
See Also
| Improve this Doc View SourceExecuteAsync(String[], CancellationToken)
Parses an array of strings using Parse(String[]).
If OptionHelp was matched, the generated help text is displayed in command line output.
If OptionVersion was matched, the generated version info is displayed in command line output.
If there were any validation errors produced from GetValidationResult(), ValidationErrorHandler is invoked.
If the parse result matches this command, the function passed to OnExecute(Func<Int32>) or OnExecuteAsync(Func<CancellationToken, Task<Int32>>) will be invoked.
Declaration
public Task<int> ExecuteAsync(string[] args, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.String[] | args | |
| System.Threading.CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Int32> | The return code from the function passed to OnExecute(Func<Int32>) or OnExecuteAsync(Func<CancellationToken, Task<Int32>>). |
ExecuteAsync<TApp>(CommandLineContext, CancellationToken)
Creates an instance of TApp, matching Arguments
to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
Declaration
public static Task<int> ExecuteAsync<TApp>(CommandLineContext context, CancellationToken cancellationToken = default(CancellationToken))
where TApp : class
Parameters
| Type | Name | Description |
|---|---|---|
| CommandLineContext | context | The execution context. |
| System.Threading.CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Int32> | The process exit code |
Type Parameters
| Name | Description |
|---|---|
| TApp | A type that should be bound to the arguments. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when attributes are incorrectly configured. |
See Also
| Improve this Doc View SourceExecuteAsync<TApp>(IConsole, String[])
Creates an instance of TApp, matching args
to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
Declaration
public static Task<int> ExecuteAsync<TApp>(IConsole console, params string[] args)
where TApp : class
Parameters
| Type | Name | Description |
|---|---|---|
| IConsole | console | The console to use |
| System.String[] | args | The arguments |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Int32> | The process exit code |
Type Parameters
| Name | Description |
|---|---|
| TApp | A type that should be bound to the arguments. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when attributes are incorrectly configured. |
See Also
| Improve this Doc View SourceExecuteAsync<TApp>(String[])
Creates an instance of TApp, matching args
to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
Declaration
public static Task<int> ExecuteAsync<TApp>(params string[] args)
where TApp : class
Parameters
| Type | Name | Description |
|---|---|---|
| System.String[] | args | The arguments |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Int32> | The process exit code |
Type Parameters
| Name | Description |
|---|---|
| TApp | A type that should be bound to the arguments. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when attributes are incorrectly configured. |
See Also
| Improve this Doc View SourceExecuteAsync<TApp>(String[], CancellationToken)
Creates an instance of TApp, matching args
to all attributes on the type, and then invoking a method named "OnExecute" or "OnExecuteAsync" if it exists.
Declaration
public static Task<int> ExecuteAsync<TApp>(string[] args, CancellationToken cancellationToken = default(CancellationToken))
where TApp : class
Parameters
| Type | Name | Description |
|---|---|---|
| System.String[] | args | The arguments |
| System.Threading.CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Int32> | The process exit code |
Type Parameters
| Name | Description |
|---|---|
| TApp | A type that should be bound to the arguments. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when attributes are incorrectly configured. |
See Also
| Improve this Doc View SourceGetFullNameAndVersion()
Gets FullName and ShortVersionGetter.
Declaration
public virtual string GetFullNameAndVersion()
Returns
| Type | Description |
|---|---|
| System.String |
GetHelpText()
Produces help text describing command usage.
Declaration
public virtual string GetHelpText()
Returns
| Type | Description |
|---|---|
| System.String | The help text. |
GetOptions()
Gets all command line options available to this command, including any inherited options.
Declaration
public IEnumerable<CommandOption> GetOptions()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<CommandOption> | Command line options. |
GetValidationResult()
Validates arguments and options.
Declaration
public ValidationResult GetValidationResult()
Returns
| Type | Description |
|---|---|
| System.ComponentModel.DataAnnotations.ValidationResult | The first validation result that is not System.ComponentModel.DataAnnotations.ValidationResult.Success if there is an error. |
GetVersionText()
Produces text describing version of the command.
Declaration
public virtual string GetVersionText()
Returns
| Type | Description |
|---|---|
| System.String | The version text. |
HandleParseResult(ParseResult)
Handle the result of parsing command line arguments.
Declaration
protected virtual void HandleParseResult(ParseResult parseResult)
Parameters
| Type | Name | Description |
|---|---|---|
| ParseResult | parseResult | The parse result. |
HelpOption(String)
Helper method that adds a help option.
Declaration
public CommandOption HelpOption(string template)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | template |
Returns
| Type | Description |
|---|---|
| CommandOption |
HelpOption(String, Boolean)
Helper method that adds a help option.
Declaration
public CommandOption HelpOption(string template, bool inherited)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | template | |
| System.Boolean | inherited |
Returns
| Type | Description |
|---|---|
| CommandOption |
OnExecute(Func<Int32>)
Defines a callback for when this command is invoked.
Declaration
public void OnExecute(Func<int> invoke)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Int32> | invoke |
OnExecuteAsync(Func<CancellationToken, Task<Int32>>)
Defines an asynchronous callback.
Declaration
public void OnExecuteAsync(Func<CancellationToken, Task<int>> invoke)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<System.Int32>> | invoke |
OnParsingComplete(Action<ParseResult>)
Adds an action to be invoked when all command line arguments have been parsed and validated.
Declaration
public void OnParsingComplete(Action<ParseResult> action)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<ParseResult> | action | The action to be invoked |
Option(String, String, CommandOptionType)
Adds a command-line option.
Declaration
public CommandOption Option(string template, string description, CommandOptionType optionType)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | template | |
| System.String | description | |
| CommandOptionType | optionType |
Returns
| Type | Description |
|---|---|
| CommandOption |
Option(String, String, CommandOptionType, Action<CommandOption>)
Adds a command-line option.
Declaration
public CommandOption Option(string template, string description, CommandOptionType optionType, Action<CommandOption> configuration)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | template | |
| System.String | description | |
| CommandOptionType | optionType | |
| System.Action<CommandOption> | configuration |
Returns
| Type | Description |
|---|---|
| CommandOption |
Option(String, String, CommandOptionType, Action<CommandOption>, Boolean)
Adds a command line option.
Declaration
public CommandOption Option(string template, string description, CommandOptionType optionType, Action<CommandOption> configuration, bool inherited)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | template | |
| System.String | description | |
| CommandOptionType | optionType | |
| System.Action<CommandOption> | configuration | |
| System.Boolean | inherited |
Returns
| Type | Description |
|---|---|
| CommandOption |
Option(String, String, CommandOptionType, Boolean)
Adds a command-line option.
Declaration
public CommandOption Option(string template, string description, CommandOptionType optionType, bool inherited)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | template | |
| System.String | description | |
| CommandOptionType | optionType | |
| System.Boolean | inherited |
Returns
| Type | Description |
|---|---|
| CommandOption |
Option<T>(String, String, CommandOptionType, Action<CommandOption>, Boolean)
Adds a command line option with values that should be parsable into T.
Declaration
public CommandOption<T> Option<T>(string template, string description, CommandOptionType optionType, Action<CommandOption> configuration, bool inherited)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | template | |
| System.String | description | |
| CommandOptionType | optionType | |
| System.Action<CommandOption> | configuration | |
| System.Boolean | inherited |
Returns
| Type | Description |
|---|---|
| CommandOption<T> | The option |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the values on the option |
Parse(String[])
Declaration
public ParseResult Parse(params string[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String[] | args | Command line arguments. |
Returns
| Type | Description |
|---|---|
| ParseResult | The result of parsing. |
ShowHelp()
Show full help.
Declaration
public void ShowHelp()
ShowHelp(Boolean)
Show full help.
Declaration
public void ShowHelp(bool usePager)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | usePager | Use a console pager to display help text, if possible. |
ShowHint()
Show short hint that reminds users to use help option.
Declaration
public virtual void ShowHint()
ShowRootCommandFullNameAndVersion()
Traverses up Parent and displays the result of GetFullNameAndVersion().
Declaration
public void ShowRootCommandFullNameAndVersion()
ShowVersion()
Displays version information that includes FullName and LongVersionGetter.
Declaration
public void ShowVersion()
VersionOption(String, Func<String>, Func<String>)
Helper method that adds a version option.
Declaration
public CommandOption VersionOption(string template, Func<string> shortFormVersionGetter, Func<string> longFormVersionGetter = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | template | |
| System.Func<System.String> | shortFormVersionGetter | |
| System.Func<System.String> | longFormVersionGetter |
Returns
| Type | Description |
|---|---|
| CommandOption |
VersionOption(String, String, String)
Helper method that adds a version option from known versions strings.
Declaration
public CommandOption VersionOption(string template, string shortFormVersion, string longFormVersion = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | template | |
| System.String | shortFormVersion | |
| System.String | longFormVersion |
Returns
| Type | Description |
|---|---|
| CommandOption |
Explicit Interface Implementations
| Improve this Doc View SourceIServiceProvider.GetService(Type)
Declaration
object IServiceProvider.GetService(Type serviceType)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | serviceType |
Returns
| Type | Description |
|---|---|
| System.Object |