views:

8

answers:

0

Because of certain special requirements of one of the C# applications I was developing, I had to write my own command-line arguments parser library. With the limited documentation available for GNU getopt (at least I couldn't find much immediately) and with my limited exposure to the open-source world, I couldn't comprehensively evaluate my library against getopt, which appears to be the de-facto command-line parser library available out there. Can someone please tell me how my library compares with GNU getopt?

Following are the features of my library:

  • Allows the client-application to define its own key-prefix.

  • Allows the client-application to pass the command-line arguments to the parser. The parser non-interactively parses the command-line arguments and returns a dictionary containing parsed values and flags, which the application can use for further processing.

  • Distinguishes between keys and flags. Only keys can take in values. Flags are directives that hold special meaning to the client application.

  • Allows the client-application to configure the parser with the set of valid keys and flags that the application can accept. The parser would use this while parsing to validate the command-line input.

  • Allows the client-application to tell the parser whether keys can accept multiple values or single value. If the application can accept multiple values, the parser would return a Dictionary<string, List<string>> containing the various keys and their corresponding values in a list. Otherwise, it would return a Dictionary<string,string>.

  • While configuring the parser, the client-application can specify which of the keys are mandatory and which are optional. The parser would check the command-line input for presence of mandatory keys.

  • The parser allows the client-application to supply the list of valid keys and flags either programmatically or by supplying the name of files containing them.