Method chaining applies successive method calls to the object returned by the preceding call. In command-line parsing, WithParsed runs first; WithNotParsed then examines the same ParserResult. section 2.8
Conditional command-line handling
Parser.Default.ParseArguments<Options>(args) .WithParsed<Options>(AsciiArt.Write) .WithNotParsed(_ => WriteLine("Usage: HelloDotnet <text> --font Big")); WithParsed executes the success action when parsing succeeds; otherwise, it returns the ParserResult so WithNotParsed can handle failure. section 2.8
Listing 2.16 Program.cs parsing command-line options with CommandLineParser
using HelloDotnet;
using CommandLine; #1
Parser.Default.ParseArguments<Options>(args) #2
.WithParsed<Options>(AsciiArt.Write) #3
.WithNotParsed(_ => #4
WriteLine("Usage: HelloDotnet <text> --font Big")); #5
Inspect the complete C# command-line parsing chain and its lambda-based failure action. section 2.8


