ConfiguratorExtensions

Contains extensions for and .

Contains extensions for IConfigurator and IConfigurator.

Methods

public static ICommandConfigurator AddAsyncDelegate(IConfigurator configurator, string name, Func<CommandContext, CancellationToken, Task<int>> func)

Adds a command without settings that executes an async delegate.

Parameters:

configurator (IConfigurator)
The configurator.
name (string)
The name of the command.
func (Func<CommandContext, CancellationToken, Task<int>>)
The delegate to execute as part of command execution.

Returns:

A command configurator that can be used to configure the command further.

public static ICommandConfigurator AddAsyncDelegate<TSettings>(IConfigurator<TSettings> configurator, string name, Func<CommandContext, CancellationToken, Task<int>> func)

Adds a command without settings that executes an async delegate.

Parameters:

configurator (IConfigurator<TSettings>)
The configurator.
name (string)
The name of the command.
func (Func<CommandContext, CancellationToken, Task<int>>)
The delegate to execute as part of command execution.

Returns:

A command configurator that can be used to configure the command further.

public static IBranchConfigurator AddBranch(IConfigurator configurator, string name, Action<IConfigurator<CommandSettings>> action)

Adds a command branch.

Parameters:

configurator (IConfigurator)
The configurator.
name (string)
The name of the command branch.
action (Action<IConfigurator<CommandSettings>>)
The command branch configuration.

Returns:

A branch configurator that can be used to configure the branch further.

public static IBranchConfigurator AddBranch<TSettings>(IConfigurator<TSettings> configurator, string name, Action<IConfigurator<TSettings>> action)

Adds a command branch.

Parameters:

configurator (IConfigurator<TSettings>)
The configurator.
name (string)
The name of the command branch.
action (Action<IConfigurator<TSettings>>)
The command branch configuration.

Returns:

A branch configurator that can be used to configure the branch further.

public static ICommandConfigurator AddDelegate(IConfigurator configurator, string name, Func<CommandContext, CancellationToken, int> func)

Adds a command without settings that executes a delegate.

Parameters:

configurator (IConfigurator)
The configurator.
name (string)
The name of the command.
func (Func<CommandContext, CancellationToken, int>)
The delegate to execute as part of command execution.

Returns:

A command configurator that can be used to configure the command further.

public static ICommandConfigurator AddDelegate<TSettings>(IConfigurator<TSettings> configurator, string name, Func<CommandContext, CancellationToken, int> func)

Adds a command without settings that executes a delegate.

Parameters:

configurator (IConfigurator<TSettings>)
The configurator.
name (string)
The name of the command.
func (Func<CommandContext, CancellationToken, int>)
The delegate to execute as part of command execution.

Returns:

A command configurator that can be used to configure the command further.

public static IConfigurator CancellationExitCode(IConfigurator configurator, int exitCode)

Tells the command line application to return the specified exit code when it's aborted through the CancellationToken. The default cancellation exit code is 130.

Parameters:

configurator (IConfigurator)
The configurator.
exitCode (int)
The exit code to return in case of cancellation.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator CaseSensitivity(IConfigurator configurator, CaseSensitivity sensitivity)

Configures case sensitivity.

Parameters:

configurator (IConfigurator)
The configuration.
sensitivity (CaseSensitivity)
The case sensitivity.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator HideOptionDefaultValues(IConfigurator configurator)

Hides the DEFAULT column that lists default values coming from the DefaultValueAttribute in the options help text.

Parameters:

configurator (IConfigurator)
The configurator.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator PropagateExceptions(IConfigurator configurator)

Tells the command line application to propagate all exceptions to the user.

Parameters:

configurator (IConfigurator)
The configurator.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator SetApplicationCulture(IConfigurator configurator, CultureInfo culture)

Sets the culture for the application.

Parameters:

configurator (IConfigurator)
The configurator.
culture (CultureInfo)
The culture.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator SetApplicationName(IConfigurator configurator, string name)

Sets the name of the application.

Parameters:

configurator (IConfigurator)
The configurator.
name (string)
The name of the application.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator SetApplicationVersion(IConfigurator configurator, string version)

Sets the version of the application.

Parameters:

configurator (IConfigurator)
The configurator.
version (string)
The version of application.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator SetExceptionHandler(IConfigurator configurator, Action<Exception, ITypeResolver> exceptionHandler)

Sets the ExceptionsHandler. Setting ExceptionHandler this way will use the default exit code of -1.

Parameters:

configurator (IConfigurator)
The configurator.
exceptionHandler (Action<Exception, ITypeResolver>)
The Action that handles the exception.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator SetExceptionHandler(IConfigurator configurator, Func<Exception, ITypeResolver, int> exceptionHandler)

Sets the ExceptionsHandler.

Parameters:

configurator (IConfigurator)
The configurator.
exceptionHandler (Func<Exception, ITypeResolver, int>)
The Action that handles the exception.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator SetHelpProvider(IConfigurator configurator, IHelpProvider helpProvider)

Sets the help provider for the application.

Parameters:

configurator (IConfigurator)
The configurator.
helpProvider (IHelpProvider)
The help provider to use.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator SetHelpProvider<T>(IConfigurator configurator)

Sets the help provider for the application.

Parameters:

configurator (IConfigurator)
The configurator.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator SetInterceptor(IConfigurator configurator, ICommandInterceptor interceptor)

Sets the command interceptor to be used.

Parameters:

configurator (IConfigurator)
The configurator.
interceptor (ICommandInterceptor)
A ICommandInterceptor.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator TrimTrailingPeriods(IConfigurator configurator, bool trimTrailingPeriods)

Tells the help provider whether or not to trim trailing period.

Parameters:

configurator (IConfigurator)
The configurator.
trimTrailingPeriods (bool)
True to trim trailing period (default), false to not.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator UseAssemblyInformationalVersion(IConfigurator configurator)

Uses the version retrieved from the AssemblyInformationalVersionAttribute as the application's version.

Parameters:

configurator (IConfigurator)
The configurator.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator UseStrictParsing(IConfigurator configurator)

Sets the parsing mode to strict.

Parameters:

configurator (IConfigurator)
The configurator.

Returns:

A configurator that can be used to configure the application further.

public static IConfigurator ValidateExamples(IConfigurator configurator)

Tells the command line application to validate all examples before running the application.

Parameters:

configurator (IConfigurator)
The configurator.

Returns:

A configurator that can be used to configure the application further.