Skip to content

Instantly share code, notes, and snippets.

@tombatron
Created April 1, 2013 03:06
Show Gist options
  • Save tombatron/5283025 to your computer and use it in GitHub Desktop.
Save tombatron/5283025 to your computer and use it in GitHub Desktop.
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);
}
}
}
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);
}
}
}
}
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