diff --git a/docs/Your-first-app-with-System-CommandLine-DragonFruit.md b/docs/Your-first-app-with-System-CommandLine-DragonFruit.md index 54f19b0e8..c91258bed 100644 --- a/docs/Your-first-app-with-System-CommandLine-DragonFruit.md +++ b/docs/Your-first-app-with-System-CommandLine-DragonFruit.md @@ -63,3 +63,38 @@ This program is equivalent to the one demonstrated in [Your first app with Syste To explore its features, take a look at [Features: overview](Features-overview.md) + +## Advanced options + +### Async support + +`System.CommandLine.DragonFruit` also makes it easy to wire in support for [Process termination handling](Process-termination-handling.md). + +Async `Main()` methods are support it and take a `CancellationToken` this cancellation token. Termination of the app triggers the cancellation of that token allowing you to handle interops. + +### Untyped arguments + +Further more `System.CommandLine.DragonFruit` still allows your `Main()` to accept args for any untyped arguments you wish to (not) handle or pass along. + + +```csharp +/// +/// A main function can also take which is hooked up to support termination (e.g CTRL+C) +/// +/// +/// +/// +/// +private static async Task Main(bool boolArg = false, CancellationToken token = default, string[] args = null) +{ + try + { + await Task.Delay(TimeSpan.FromSeconds(20), token); + } + catch (OperationCanceledException) + { + return 1; + } + return 0; +} +```