help-gengetopt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [help-gengetopt] mutually exclusive group of options


From: Papp Gyozo (VBuster)
Subject: Re: [help-gengetopt] mutually exclusive group of options
Date: Thu, 14 Jun 2007 12:47:03 +0200

> 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")

I see in dependant_option.h_skel which condition is needed to modify/extend:

if (args_info->@address@hidden && ! args_info->@address@hidden)
  {
...
  }

But I don't know how. (It was a long time ago when I made changes to the 
gengetopt source...)
So here is my theory as a pseudo code: 

if (args_info->@address@hidden 
    && !(args_info->@address@hidden

#if @dep_option@ is flag 
        || args_info->@address@hidden 
#elif @dep_option@ has arg
        || !args_info->@address@hidden
#endif

        ))
  {
...
  }

AFAIR gengen supports some kind of #if .. #endif contructs.

> 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
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]