[Mono-list] C# command line parsing library

gsscoder zero.one.etc at gmail.com
Thu May 17 19:28:29 UTC 2012

Please give a look to my library.

Project Home: http://commandline.codeplex.com/
Source Repo: https://github.com/gsscoder/commandline

Reference it or add two .cs file to your project (/CommandLine.cs/ | parser
and /CommandLineText.cs/ | help builder).

Create a target class for receive parsed values (and handle help screen

class Options {
      *[Option("r", "read", Required=True, HelpText="Input file to be
      public string InputFile { get; set; }

      *[Option("v", "verbose", HelpText="Output all messages to standard
      public bool Verbose { get; set; }

      public string GetUsage() {
        var help = new *HelpText*(new HeadingInfo("git-sample", "0.1"));
        help.Copyright = new CopyrightInfo("mr the author", 2005, 2012);
        help.AddPreOptionsLine("some custom stuff here");
        return help;

then with one instruction you can parse command line arguments:

static void Main(string[] args) {
      var options = new Options();
      if (*CommandLineParser.Default.ParseArguments(args, options)*) {
        // Consume values here
        if (options.Verbose) Console.WriteLine("Filename: {0}",

Have fun!


View this message in context: http://mono.1490590.n4.nabble.com/C-command-line-parsing-library-tp1502157p4643470.html
Sent from the Mono - General mailing list archive at Nabble.com.

More information about the Mono-list mailing list