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
TEndpoint
The 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
endpoint
TEndpointThe 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
args
IReadOnlyList<string>the console arguments.
cancellationToken
CancellationTokenUsed 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
args
IReadOnlyList<string>the console arguments.
cancellationToken
CancellationTokenUsed to cancel the request.
Returns
GetSubCommand(string)
Creates a sub-IEndpointCommand based on the given name
.
protected virtual IEndpointCommand? GetSubCommand(string name)
Parameters
name
string
Returns
- IEndpointCommand
The IEndpointCommand or
null
if thename
does 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
args
IReadOnlyList<string>The command-line to check for input data.
Returns
- T
Type Parameters
T
The type of object to read.