Re: mutually exclusive group of options

Lorenzo Bettini <[email protected]>
Newsgroups gmane.comp.gnu.gengetopt.general
Message-ID <[email protected]>
Papp Gyozo (VBuster) wrote:
> Hi
> 
> I've encountered a problem and don't know how to resolve it. I'm developing a commandline tool which can use either of two shared libraries (.so in short) but only one of those at a time. Furthermore, both .so require different options which are available (meaningful) only if the corresponding .so is chosen. For example:
> 
>  scan --init   --dir1=... --dir2=... ; create an own scanning process
> 
> or
> 
>  scan --attach --address=... ; attach to a daemon
> 
> (I hope it is clearer a little bit now what I'm talking about.)
> 
> I know I can specify "init" and "attach" as mutually exclusive group options but I don't know how to induce gengetopt to allow dir options only if --init is given and --address if --attach is given. 
> 
> Any ideas? Thanks in advance
> 

Hi there

you can use the "dependon" specification of an option:

dependon
    this option depends on another option (whose long name description
is specified). If this option is given at command line but not the
option it depends on, an error will be generated.

for instance,

option  "dependant"         D
   "option that depends on str-opt" int optional dependon="str-opt"

does this solve your problem?

hope to hear from you soon
cheers
	Lorenzo

-- 
Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
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.