Class CommandLineApplicationExtensions
Inheritance
System.Object
CommandLineApplicationExtensions
Assembly: McMaster.Extensions.CommandLineUtils.dll
Syntax
public static class CommandLineApplicationExtensions
Methods
|
Improve this Doc
View Source
Argument<T>(CommandLineApplication, String, String, Boolean)
Adds a command line argument with values that should be parsable into T
.
Declaration
public static CommandArgument<T> Argument<T>(this CommandLineApplication app, string name, string description, bool multipleValues = false)
Parameters
Type |
Name |
Description |
CommandLineApplication |
app |
|
System.String |
name |
|
System.String |
description |
|
System.Boolean |
multipleValues |
|
Returns
Type Parameters
|
Improve this Doc
View Source
HelpOption(CommandLineApplication)
Adds the help option with the template -?|-h|--help
.
Declaration
public static CommandOption HelpOption(this CommandLineApplication app)
Parameters
Returns
|
Improve this Doc
View Source
HelpOption(CommandLineApplication, Boolean)
Adds the help option with the template -?|-h|--help
.
Declaration
public static CommandOption HelpOption(this CommandLineApplication app, bool inherited)
Parameters
Returns
|
Improve this Doc
View Source
OnExecute(CommandLineApplication, Action)
Sets the command execution handler with a return code of 0
.
Declaration
public static void OnExecute(this CommandLineApplication app, Action action)
Parameters
Type |
Name |
Description |
CommandLineApplication |
app |
|
System.Action |
action |
An action to invoke when the command is selected.
|
|
Improve this Doc
View Source
OnExecuteAsync(CommandLineApplication, Func<CancellationToken, Task>)
Sets an async command execution handler with a return code of 0
.
Declaration
public static void OnExecuteAsync(this CommandLineApplication app, Func<CancellationToken, Task> action)
Parameters
Type |
Name |
Description |
CommandLineApplication |
app |
|
System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task> |
action |
An asynchronous action to invoke when the command is selected..
|
|
Improve this Doc
View Source
OnValidationError(CommandLineApplication, Action<ValidationResult>)
Sets an action to invoke, but only when there is a validation error.
Declaration
public static void OnValidationError(this CommandLineApplication app, Action<ValidationResult> action)
Parameters
Type |
Name |
Description |
CommandLineApplication |
app |
|
System.Action<System.ComponentModel.DataAnnotations.ValidationResult> |
action |
|
|
Improve this Doc
View Source
OnValidationError(CommandLineApplication, Func<ValidationResult, Int32>)
Sets an action to invoke, but only when there is a validation error.
Declaration
public static void OnValidationError(this CommandLineApplication app, Func<ValidationResult, int> action)
Parameters
Type |
Name |
Description |
CommandLineApplication |
app |
|
System.Func<System.ComponentModel.DataAnnotations.ValidationResult, System.Int32> |
action |
|
|
Improve this Doc
View Source
Option<T>(CommandLineApplication, String, String, CommandOptionType)
Adds a command-line option with values that should be parsable into T
.
Declaration
public static CommandOption<T> Option<T>(this CommandLineApplication app, string template, string description, CommandOptionType optionType)
Parameters
Returns
Type Parameters
|
Improve this Doc
View Source
Option<T>(CommandLineApplication, String, String, CommandOptionType, Action<CommandOption>)
Adds a command-line option with values that should be parsable into T
.
Declaration
public static CommandOption<T> Option<T>(this CommandLineApplication app, string template, string description, CommandOptionType optionType, Action<CommandOption> configuration)
Parameters
Returns
Type Parameters
|
Improve this Doc
View Source
Option<T>(CommandLineApplication, String, String, CommandOptionType, Boolean)
Adds a command-line option with values that should be parsable into T
.
Declaration
public static CommandOption<T> Option<T>(this CommandLineApplication app, string template, string description, CommandOptionType optionType, bool inherited)
Parameters
Returns
Type Parameters
|
Improve this Doc
View Source
VerboseOption(CommandLineApplication)
Adds the verbose option with the template -v|--verbose
.
Declaration
public static CommandOption VerboseOption(this CommandLineApplication app)
Parameters
Returns
|
Improve this Doc
View Source
VerboseOption(CommandLineApplication, String)
Adds the verbose option with the template -v|--verbose
.
Declaration
public static CommandOption VerboseOption(this CommandLineApplication app, string template)
Parameters
Returns
|
Improve this Doc
View Source
VersionOptionFromAssemblyAttributes(CommandLineApplication, Assembly)
Finds System.Reflection.AssemblyInformationalVersionAttribute on assembly
and uses that
to set OptionVersion.
Uses the Version that is part of the System.Reflection.AssemblyName of the specified assembly
if no System.Reflection.AssemblyInformationalVersionAttribute is applied.
Declaration
public static CommandOption VersionOptionFromAssemblyAttributes(this CommandLineApplication app, Assembly assembly)
Parameters
Returns
Exceptions
Type |
Condition |
System.ArgumentNullException |
Either app or assembly is null .
|
|
Improve this Doc
View Source
VersionOptionFromAssemblyAttributes(CommandLineApplication, String, Assembly)
Finds System.Reflection.AssemblyInformationalVersionAttribute on assembly
and uses that
to set OptionVersion.
Uses the Version that is part of the System.Reflection.AssemblyName of the specified assembly
if no System.Reflection.AssemblyInformationalVersionAttribute is applied.
Declaration
public static CommandOption VersionOptionFromAssemblyAttributes(this CommandLineApplication app, string template, Assembly assembly)
Parameters
Returns
Exceptions
Type |
Condition |
System.ArgumentNullException |
Either app or assembly is null .
|