CommandApp

The entry point for a command line application.

The entry point for a command line application.

Constructors

public CommandApp(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 DefaultCommandConfigurator SetDefaultCommand<TCommand>()

Sets the default command.

Returns:

A DefaultCommandConfigurator that can be used to configure the default command.