Created
April 1, 2013 03:06
-
-
Save tombatron/5283025 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TestingApplication | |
{ | |
using CommandLine; | |
using CommandLine.Text; | |
public class Options | |
{ | |
[VerbOption("testverbone", HelpText = "Test Verb One.")] | |
public RssSubOptions RssVerb { get; set; } | |
[HelpOption] | |
public string GetUsage() | |
{ | |
return HelpText.AutoBuild(this, current => HelpText.DefaultParsingErrorsHandler(this, current)); | |
} | |
[HelpVerbOption] | |
public string GetUsage(string verb) | |
{ | |
return HelpText.AutoBuild(this, verb); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TestingApplication | |
{ | |
using System; | |
using CommandLine; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
String invokedVerb; | |
Object invokedVerbInstance; | |
Options options = new Options(); | |
if (!Parser.Default.ParseArguments(args, options, (verb, subOptions) => | |
{ | |
invokedVerb = verb; | |
invokedVerbInstance = subOptions; | |
})) | |
{ | |
Environment.Exit(CommandLine.Parser.DefaultExitCodeFail); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TestingApplication | |
{ | |
using System; | |
using CommandLine; | |
public class TestVerbOneSubOptions | |
{ | |
[Option('b', "begin-date", HelpText = "Begin date.")] | |
public DateTime BeginDate { get; set; } | |
[Option('n', "no-update", HelpText = "No update.")] | |
public bool NoUpdate { get; set; } | |
[Option('s', "silent", HelpText = "Silence!")] | |
public bool Silent { get; set; } | |
[Option('c', "criteria", HelpText = "Criteria.")] | |
public bool Criteria { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment