Re: flag setting issues with override

"Papp Gyozo (VBuster)" <[email protected]> Fri, 05 Feb 2010 17:18:37 +0100
Newsgroups gmane.comp.gnu.gengetopt.general
Message-ID <[email protected]>
Hi there, 

> The detailed scenario is that config file is parsed first and then the
> command line. The latter has precedence over the former, that is, command
> line arguments overrides option values given in config file. In my
> understanding "override" should mean "confirm" in case of flags at least
> when different settings are originated from different sources (or different
> runs of gengetopt_internal()).

In short term, I'm thinking of introducing a new parameter for the parser to check if flag is set more than once. This way we could preserve the original behaviour and support the new one as I suggested yesterday.

>     struct getoptions_params    ggo = {
>                                     1, // override what is in cmdline struct
>                                     1, // initialize struct w/ default
> values
>                                     0, // check required
>                                     0, // check ambiguity

check ambiguity would be fine but I avoid to overload with additional functionality.
The new one could be named as check flag or something like that to refer this problem.

In a long run, I would prefer to change flag option generation as to gcc's options.
I mean to generate to separate options for setting and reseting flags:
  -flag    # to enable (switch on) the `flag'
  -no-flag # to disable (switch off) the `flag'

I hope this way we could avoid several problems and misunderstandings around flag options. Unfortunately it breaks compatibility.


What do think?

Best regards, 
Gyozo Papp