1

I built a program with an config file parser and cli options.

My goal was to have this order of priority :

  1. CLI options configuration
  2. Mandatory configuration file
  3. Hardcoded default configuration

While parsing my CLI arguments with argp I need to read the path to the config file first (which is NOT an option) then other CLI options to override the config file settings.

As described in the glibc argp documentation, options are read first then non-option arguments, unless you use the ARGP_IN_ORDER flag. In this case arguments are read from first to last (option or not).

In this case, my first mandatory argument is the path to my config file. All behave as expected, except the usage output.

I have this :

Usage: myprogramm [OPTION...] CONFIGURATIONFILE

I need this :

Usage: myprogramm CONFIGURATIONFILE [OPTION...]

Is there a way to place non-optional arguments first in the Usage output?

MicroCheapFx
  • 392
  • 1
  • 2
  • 15
  • 1
    BTW, if you are allowed to use boost: [Boost.ProgramOptions](http://www.boost.org/doc/libs/1_58_0/doc/html/program_options.html) provides a pretty nice interface for doing such things – Narek Atayan Nov 08 '16 at 08:27
  • Î know, thank you, but I am using argp BECAUSE we are getting rid of Boost with C++11 ^^ – MicroCheapFx Nov 08 '16 at 08:38

0 Answers0