Replies: 1 comment 1 reply
-
|
I wanted to disable System.CommandLine's handling of ctrl-c... and after hunting through the code wrote this: var parse = Cli.RootCommand.Parse(args);
parse.InvocationConfiguration.EnableDefaultExceptionHandler = false;
// Disable ^c (etc.) handling
parse.InvocationConfiguration.ProcessTerminationTimeout = null;
var canTok = SetupInterrupt();
return await parse.InvokeAsync(cancellationToken: canTok); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My console app already has termination handlers for ctrlc/break etc., I configure the environment before calling any command handlers, and I use a my cancellation token in async methods.
I am converting some commands to be async when invoked from the CLI, and I get a cancellation token passed in along with the parse arguments.
Per the docs it looks like CLI configs its own ctrlc handler, and connects the async cancellation token to be signaled.
This duplicates logic my app already manages, how can I e.g. prevent duplicate termination handling being created, pass in my own cancellation token to the CLI logic, reuse the CLI logic cancellation token, etc.?
Beta Was this translation helpful? Give feedback.
All reactions