From 032e4c7e2d66a01aaf7889cb379142252195936c Mon Sep 17 00:00:00 2001 From: Stephen Price Date: Sun, 8 Apr 2018 15:49:58 +0800 Subject: [PATCH 1/3] Added simple quick start example for C# to the README.md --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/README.md b/README.md index e20d9b90..acb67113 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 has been enabled. Current Arguments: -v {o.Verbose}"); + Console.WriteLine("Quick Start Example! App is in Verbose mode so verbose messages will be shown!"); + } + else + { + Console.WriteLine($"Current Arguments: -v {o.Verbose}"); + Console.WriteLine("Quick Start Example!"); + } + }); + } + } +} +``` + C# Examples: ```csharp From da54cf217b6f440c036c2dbc71441869304dcd41 Mon Sep 17 00:00:00 2001 From: Stephen Price Date: Sun, 8 Apr 2018 15:56:19 +0800 Subject: [PATCH 2/3] Shortened message to remove scrollbar on Github --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92615d38..6fe2a4e5 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ namespace QuickStart if (o.Verbose) { Console.WriteLine($"Verbose output has been enabled. Current Arguments: -v {o.Verbose}"); - Console.WriteLine("Quick Start Example! App is in Verbose mode so verbose messages will be shown!"); + Console.WriteLine("Quick Start Example! App is in Verbose mode!"); } else { From 6ce423d63015e827517d3603af495c105314f2ed Mon Sep 17 00:00:00 2001 From: Stephen Price Date: Sun, 8 Apr 2018 15:58:31 +0800 Subject: [PATCH 3/3] Shortened message to remove scrollbar --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fe2a4e5..1f031da2 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ namespace QuickStart { if (o.Verbose) { - Console.WriteLine($"Verbose output has been enabled. Current Arguments: -v {o.Verbose}"); + Console.WriteLine($"Verbose output enabled. Current Arguments: -v {o.Verbose}"); Console.WriteLine("Quick Start Example! App is in Verbose mode!"); } else