CommandApp<>

The entry point for a command line application with a default command.

The entry point for a command line application with a default command.

Constructors

public CommandApp`1(ITypeRegistrar registrar = null)

Initializes a new instance of the CommandApp class.

Parameters:

registrar (ITypeRegistrar)
The registrar.

Methods

public void Configure(Action<IConfigurator> configuration)

Configures the command line application.

Parameters:

configuration (Action<IConfigurator>)
The configuration.
public int Run(IEnumerable<string> args, CancellationToken cancellationToken = default)

Runs the command line application with specified arguments.

Parameters:

args (IEnumerable<string>)
The arguments.
cancellationToken (CancellationToken)
A CancellationToken that can be used to abort the application.

Returns:

The exit code from the executed command.

public Task<int> RunAsync(IEnumerable<string> args, CancellationToken cancellationToken = default)

Runs the command line application with specified arguments.

Parameters:

args (IEnumerable<string>)
The arguments.
cancellationToken (CancellationToken)
A CancellationToken that can be used to abort the application.

Returns:

The exit code from the executed command.

public CommandApp<TDefaultCommand> WithData(object data)

Sets data that will be passed to the command via the CommandContext.

Parameters:

data (object)
The data to pass to the default command.

Returns:

The same CommandApp instance so that multiple calls can be chained.

public CommandApp<TDefaultCommand> WithDescription(string description)

Sets the description of the default command.

Parameters:

description (string)
The default command description.

Returns:

The same CommandApp instance so that multiple calls can be chained.