Menu

Welcome to Open Discussion

2005-01-04
2013-04-02
  • Nobody/Anonymous

    Welcome to Open Discussion

     
    • vitaut

      vitaut - 2008-03-22

      Great work!

      This is the only sane .Net library for command-line option parsing I've found in the Web.

      From my point of view it lacks only few features. The first is a trivial but working example at the beginning of the documentation to reduce entry level for new users because not everyone wants to read through the documentation.

      Something like the following would be nice:

      using System;
      using CommandLine.OptParse;

      class Options
      {
          [OptDef(OptValType.ValueOpt)]
          [LongOptionName("greeting")]
          public string Greeting = "Hello, world!";
      }

      class Program
      {
          static void Main()
          {
              Options options = new Options();
              ParserFactory.BuildParser(options).Parse();
              Console.WriteLine(options.Greeting);
          }
      }

      Another thing that could be improved is exception handling. It would be better to have one exception type for invalid value case, including the following example from the documentation:

          public string ExampleEnumPropAsString
          {
              get { return _exampleEnumProp.ToString(); }
              set
              {
                  switch (value.ToLower())
                  {
                      case "first": _exampleEnumProp = ExamplePropertyEnum.First; break;
                      case "second": _exampleEnumProp = ExamplePropertyEnum.Second; break;
                      default:
                          throw new ArgumentException(
                              "Invalid value for the example-enum-prop option");
                  }
              }
          }

      However, in the latter case it will be TargetInvocationException with inner exception ArgumentException.

      And thanks for license change.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.