The new release of GNU Gengetopt is available.
Apart from the classical bugfixes, the main change in this release is the generated code which should be now shorter (in most cases) and, most of all, cleaner and easier to understand (hopefully). Surely it should be easier now to add some new features. In particular the handling of an option (and its possible argument) is completely delegate to a single function (update_arg) which can handle all the combinations of kinds of options (required or optional options, options with optional arguments, all the types, etc.); also the corresponding function for dealing with multiple options internally relies on this function.
During the refactoring of the generated code, I took the chance to add some requested features (and this somehow proved that the new generated code is easier to deal with):
- the automatic error printing done by the getopt_long function can now be suppressed by passing an additional parameter to the generated function (so that the programmer can customize the error reporting or also consider what getopt_long thinks is an error not an error)
- options with values can now be given a specific type (the same types available for other options), and, in particular, the type enum is available for this kind of options, and this will correspond to a C enum in the generated file
- when there are more than one kind of help output (e.g., in the presence of hidden options) the generated help strings avoid duplicating string constant, so that the memory footprint should be minor
- options can be given an additional field, details, where one can specify a more verbose option description; this will add to the generated parser the command line option --detailed-help; in this case also the details will be printed. This way, the user can have the standard help output and a more detailed one.
- the programmer can completely handle manually --help and --version, even redefine them. In particular, if the gengetopt options --no-help and --no-version are specified, gengetopt will not generate the automatic --help and --version options in the generated parser.