Search Results for

    Show / Hide Table of Contents

    Class CommandLineApplicationExtensions

    Helper methods for CommandLineApplication.

    Inheritance
    System.Object
    CommandLineApplicationExtensions
    Namespace: McMaster.Extensions.CommandLineUtils
    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 Description
    CommandArgument<T>
    Type Parameters
    Name Description
    T
    | 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
    Type Name Description
    CommandLineApplication app
    Returns
    Type Description
    CommandOption
    | 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
    Type Name Description
    CommandLineApplication app
    System.Boolean inherited
    Returns
    Type Description
    CommandOption
    | 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
    Type Name Description
    CommandLineApplication app
    System.String template
    System.String description
    CommandOptionType optionType
    Returns
    Type Description
    CommandOption<T>
    Type Parameters
    Name Description
    T
    | 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
    Type Name Description
    CommandLineApplication app
    System.String template
    System.String description
    CommandOptionType optionType
    System.Action<CommandOption> configuration
    Returns
    Type Description
    CommandOption<T>
    Type Parameters
    Name Description
    T
    | 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
    Type Name Description
    CommandLineApplication app
    System.String template
    System.String description
    CommandOptionType optionType
    System.Boolean inherited
    Returns
    Type Description
    CommandOption<T>
    Type Parameters
    Name Description
    T
    | 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
    Type Name Description
    CommandLineApplication app
    Returns
    Type Description
    CommandOption
    | 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
    Type Name Description
    CommandLineApplication app
    System.String template
    Returns
    Type Description
    CommandOption
    | 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
    Type Name Description
    CommandLineApplication app
    System.Reflection.Assembly assembly
    Returns
    Type Description
    CommandOption
    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
    Type Name Description
    CommandLineApplication app
    System.String template
    System.Reflection.Assembly assembly
    Returns
    Type Description
    CommandOption
    Exceptions
    Type Condition
    System.ArgumentNullException

    Either app or assembly is null.

    • Improve this Doc
    • View Source
    In This Article
    Back to top