diff --git a/README.md b/README.md index 3dda317d..1f031da2 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,43 @@ You can utilize the parser library in several ways: 1. Create a class to define valid options, and to receive the parsed options. 2. Call ParseArguments with the args string array. +C# Quick Start: + +```csharp +using System; +using CommandLine; + +namespace QuickStart +{ + class Program + { + public class Options + { + [Option('v', "verbose", Required = false, HelpText = "Set output to verbose messages.")] + public bool Verbose { get; set; } + } + + static void Main(string[] args) + { + Parser.Default.ParseArguments(args) + .WithParsed(o => + { + if (o.Verbose) + { + Console.WriteLine($"Verbose output enabled. Current Arguments: -v {o.Verbose}"); + Console.WriteLine("Quick Start Example! App is in Verbose mode!"); + } + else + { + Console.WriteLine($"Current Arguments: -v {o.Verbose}"); + Console.WriteLine("Quick Start Example!"); + } + }); + } + } +} +``` + C# Examples: ```csharp