Re: mutually exclusive group of options
"Papp Gyozo (VBuster)" <[email protected]>
| Newsgroups | gmane.comp.gnu.gengetopt.general |
|---|---|
| Message-ID | <[email protected]> |
> 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->@option_var_name@_given && ! args_info->@dep_option@_given)
{
...
}
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->@option_var_name@_given
&& !(args_info->@dep_option@_given
#if @dep_option@ is flag
|| args_info->@dep_option@_flag
#elif @dep_option@ has arg
|| !args_info->@dep_option@_arg
#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
>