views:

265

answers:

3

Any good alternative written in C to replace Boost.Program_options? Given it's able to parse:

  1. Short options like -h
  2. Long options like --help --input-file
  3. Parse repeated keys/options
  4. Accepts key-value pairs: --mysql=/usr/lib
  5. Parsing environmental variables and XML/INI files is optional.
+8  A: 

If you are okay with the GPL license, you want GNU getopt.

R Samuel Klatchko
+3  A: 

POSIX has getopt, glibc adds getopt_long. Both the links I posted have examples. None of them parses environment variables of XML/INI files, but those two don't really belong with command-line options parsing. A quick google search results in libraries to be able to do those things though.

Alok
+2  A: 

GLib comes with a commandline option parser that supports your first four requirements, and also a key-value file parser that supports the fifth.

Juliano