Table of Contents

Interface ICommandAppExecutor

Namespace
Ploch.CommandLine.Spectre
Assembly
Ploch.CommandLine.Spectre.dll

Defines an interface for executing command-line applications.

public interface ICommandAppExecutor

Remarks

An executor permits one execution attempt: an attempt may build the host it runs over, and that host cannot be built again, so every attempt consumes the executor whatever its outcome. A second Run(params IEnumerable<string>) or RunAsync(params IEnumerable<string>) on the same instance throws InvalidOperationException. To run again, build a new executor over a freshly configured command application — ConfigureCommandApp(Action<IConfigurator>) does both when the application was built through AppBuilder.

For an executor returned by ConfigureCommandApp(Action<IConfigurator>), a run that reaches command resolution builds the IHost behind it, for dependency injection, configuration and logging only; a parse failure or --version returns before any host exists. The library never starts that host: a CLI command is the unit of work, so it invokes neither StartAsync nor StopAsync on a registered IHostedService, and it disposes a host it built when the run ends. Starting the host around the command is a possible 1.x feature, tracked as PLO-785.

Methods

Run(params IEnumerable<string>)

Executes the command-line application synchronously with the specified arguments.

RunAsync(params IEnumerable<string>)

Executes the command-line application asynchronously with the specified arguments.