Table of Contents

Class Executor<TEndpoint, TCommand>

Namespace
TypedRest.CommandLine
Assembly
TypedRest.CommandLine.dll

Executes IEndpointCommands based on command-line arguments.

public class Executor<TEndpoint, TCommand> where TEndpoint : EntryEndpoint where TCommand : IEndpointCommand

Type Parameters

TEndpoint

The type of entry endpoint to use for CliEndpointProvider<T>. Must have suitable constructors.

TCommand

The type of entry command to use. Must have a constructor that takes a single TEndpoint.

Inheritance
Executor<TEndpoint, TCommand>
Inherited Members

Constructors

Executor()

Creates an executor using the default CliEndpointProvider<T>.

public Executor()

Executor(IEndpointProvider<TEndpoint>)

Creates an executor using a custom endpointProvider.

public Executor(IEndpointProvider<TEndpoint> endpointProvider)

Parameters

endpointProvider IEndpointProvider<TEndpoint>

Methods

ExecuteAsync(TCommand, IReadOnlyList<string>, CancellationToken)

Executes a command and performs error handling.

protected virtual Task<int> ExecuteAsync(TCommand command, IReadOnlyList<string> args, CancellationToken cancellationToken)

Parameters

command TCommand

The command used to execute.

args IReadOnlyList<string>

the console arguments to parse.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task<int>

The exit code.

NewCommand(TEndpoint)

Instantiates a TCommand.

protected virtual TCommand NewCommand(TEndpoint endpoint)

Parameters

endpoint TEndpoint

Returns

TCommand

RunAsync(IReadOnlyList<string>, CancellationToken)

Creates a new endpoint and command and executes it using the specified command-line arguments.

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

Parameters

args IReadOnlyList<string>

the console arguments to parse.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task<int>

The exit code.