Closed
Description
The various SetHandler
overloads are great for hooking up simple actions.
However, if you need a cancellation token none of these are available and you have to use:
command.SetHandler(
async context =>
await MyMethod(
context.ParseResult.GetValueForArgument(anArgument)),
context.ParseResult.GetValueForOption(anOption),
context.GetCancellationToken()));
Which feels very clunky compared to the methods without the need for cancellation.
Please could we add:
command.SetCancellableHandler(
async (arg, opt, token) =>
await MyMethod(
arg,
opt,
token),
anArgument,
anOption);
// or even
command.SetCancellableHandler(
MyMethod,
anArgument,
anOption);
I realise this could be done with extension methods, but they wouldn't have access to the internal GetValueForHandlerParameter
that the overloads of SetHandler
do.
Metadata
Metadata
Assignees
Labels
No labels