Re: mutually exclusive group of options

"Papp Gyozo (VBuster)" <[email protected]>
Newsgroups gmane.comp.gnu.gengetopt.general
Message-ID <[email protected]>
> So the only solution is to make --init and --attach belong to the same 
> group (so that they're exclusive with each other), and then use dependon
> for all the other options.
> 
> Unfortunately, this requires --init to be specified explicitly (which is
> not what you want...).
> 
> Do you have any proposals of a new mechanism to solve this?

Well a sort of ... but I haven't think it over yet. Let's see what I've already:

We agree that the bottleneck is the obligatory presence of --init option.
What would happen if such a base option (btw how do you call it when other options depend on it?) may not be required if it had a default value? (Or enabled/switched on by default like "flag on")

defgroup "mode"
groupoption "init"   default="..." group="mode"
groupoption "attach"               group="mode"

option "dir1" dependon="init"
option "dir2" dependon="init"

option "attach-arg" dependon="attach"

This way all below are valid:

  scan --dir1
  scan --dir2
  scan --dir1 --dir2
  scan --init --dir1 --dir2 
etc.

but these generate errors in parsing phase:

  scan --init --attach-arg
  scan --attach --dir1
  scan --attach --dir2

What do you think about this?

> Of course, one could perform checks manually, but one would want most of
> the checks to be performed automatically, right? :-)

Of course, I can work around it and I think I'll indeed do that while gengetopt comes up with this new feature. I just started to think louldy in the list ...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.