Class EndpointCommand<TEndpoint>
- Namespace
- TypedRest.CommandLine.Commands
- Assembly
- TypedRest.CommandLine.dll
Command operating on an IEndpoint.
public abstract class EndpointCommand<TEndpoint> : IEndpointCommand where TEndpoint : IEndpoint
Type Parameters
TEndpointThe specific type of IEndpoint to operate on.
- Inheritance
-
EndpointCommand<TEndpoint>
- Implements
- Derived
- Inherited Members
Constructors
EndpointCommand(TEndpoint)
Command operating on an IEndpoint.
protected EndpointCommand(TEndpoint endpoint)
Parameters
endpointTEndpointThe endpoint this command operates on.
Fields
Endpoint
The endpoint this command operates on.
protected readonly TEndpoint Endpoint
Field Value
- TEndpoint
Properties
Console
The text input/output device used for user interaction.
public IConsole Console { get; set; }
Property Value
Methods
ExecuteAsync(IReadOnlyList<string>, CancellationToken)
Parses command-line arguments and executes the resulting operation.
public virtual Task ExecuteAsync(IReadOnlyList<string> args, CancellationToken cancellationToken = default)
Parameters
argsIReadOnlyList<string>the console arguments.
cancellationTokenCancellationTokenUsed to cancel the request.
Returns
ExecuteInnerAsync(IReadOnlyList<string>, CancellationToken)
Parses command-line arguments and executes the resulting operation when no additional sub-IEndpointCommand is specified.
protected virtual Task ExecuteInnerAsync(IReadOnlyList<string> args, CancellationToken cancellationToken = default)
Parameters
argsIReadOnlyList<string>the console arguments.
cancellationTokenCancellationTokenUsed to cancel the request.
Returns
GetSubCommand(string)
Creates a sub-IEndpointCommand based on the given name.
protected virtual IEndpointCommand? GetSubCommand(string name)
Parameters
namestring
Returns
- IEndpointCommand
The IEndpointCommand or
nullif thenamedoes not match.
Input<T>(IReadOnlyList<string>)
Reads an input object (usually in JSON format) either from the command-line or stdin.
protected virtual T Input<T>(IReadOnlyList<string> args)
Parameters
argsIReadOnlyList<string>The command-line to check for input data.
Returns
- T
Type Parameters
TThe type of object to read.