Replies: 1 comment
-
#701 is probably related to this |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I gave Spectre.Console.Cli a spin by porting an existing project, and one of the pain points was co-operative cancellation of asynchronous commands. The library I had been using previously passed a
CancellationToken
to its abstract "execute" method, so I had a bunch of existing code that expected to receive one. I had to resort to constructor injection ofIHostApplicationLifetime
to get itsStoppingToken
in every command, which is a lot of boilerplate when you have more than a trivial number of commands.It seems like Spectre could add a
CommandContext.CancellationToken
property without breaking its existing API. By default, this could beCancellationToken.None
. Then, an overload could be added toCommandApp.RunAsync()
that accepts aCancellationToken
and propagates it to theCommandContext
. (ItsCanBeCanceled
property would allow implementers to discover whether cancellation is "wired up" or not.)Would you be interested in this feature? I think I could manage a pull request that adds it.
Beta Was this translation helpful? Give feedback.
All reactions