-
-
Notifications
You must be signed in to change notification settings - Fork 261
Closed
Labels
enhancementhelp wantedWe would be willing to take a well-written PR to help fix this.We would be willing to take a well-written PR to help fix this.
Milestone
Description
Describe the bug
Consider the following code snippet:
public async Task<int> ExecuteAsync<TCommand>(string[] args, CancellationToken cancellationToken = default) where TCommand:class
{
cancellationToken.ThrowIfCancellationRequested();
var app = new CommandLineApplication<TCommand>();
try
{
app.Conventions
.UseDefaultConventions()
.UseConstructorInjection(Services);
return app.Execute(args);
}
catch (CommandParsingException e)
{
await app.Out.WriteLineAsync(e.Message);
app.ShowHelp();
return -1;
}
}
The API doesn't expose ExecuteAsync(args, cancellationToken)
.
To Reproduce
There is no ExecuteAsync method that takes a cancellation token, which in turn complicates matters when TCommand
implements an ExecuteAsync method, which uses a cancellation token.
Expected behavior
The expectation is that all methods on CommandLineApplication
exposes async methods that accepts a cancellation token, so that a long running application can be cancelled.
Additional context
The need exists to signal to the instance of TCommand
that is running asynchronously that processing should be cancelled for whatever reason, e.g. the user pressed CTRL+C.
Stev3nsen, Poltuu, manne and schrufygroovy
Metadata
Metadata
Assignees
Labels
enhancementhelp wantedWe would be willing to take a well-written PR to help fix this.We would be willing to take a well-written PR to help fix this.