Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost program_options - is there a way to make abbreviations for short options
From: Deniz Bahadir (dbahadir_at_[hidden])
Date: 2014-06-06 11:56:38


I am not sure, if this is possible, but I guess not.

However, you have two possibilities which come near to what you want

You could always just create an additional "long"-option which has the
abbreviated name.
Of course, in general you will have to call your option with
double-dashes ("--") prefixed, instead of a single dash ("-"). However,
when adding "allow_long_disguise" [1] to your style, you then can call
your abbreviated long-option with a single dash (if this is important
for you).

Alternatively, you could add "allow_guessing" [1] to your style and just
type the begin of your long-option's name as long as this unambiguously
identifies the long-option.
With your example you could e.g. write "--re" to match "--resolution"
and "--ra" to match "--raster-level". (Using "allow_long_disguise" [1]
style should be possible, too.) However, "--rl" to match
"--raster-level" will probably not work. (I did not explicitly check.)

Note however: Whichever solution you choose, both require to take
special care.
With the first solutions you must be aware that you have at least two
different options that might set the same variable.
With the second solution you must take care, that no (entire)
long-option name is ever a prefix to another (even longer) long-option name.
Additionally, you probably will not get the original
help-description-string that you wanted.

I hope that helps.


PS: Because I am not the developer of boost::program_options (that is
Vladimir Prus) I might be mistaken. If I might have said something wrong
or stupid please correct me and let us all know the correct/better solution.


Am 06.06.2014 17:10, schrieb tenspd137 .:
> Hi all,
> I was trying to figure out if there is a way to make the short options
> use more than one letter to create an abbrieviation. For example:
> desc.add_options()
> ("resolution","re","Choose resolution")
> ("raster-level,"rl","Chhose raster mode")
> ....
> I know that by convention and definition, short options are just
> -(letter), so that when you ask to print help, you get something like:
> -r [--resolution] arg
> -r [--raster-level] arg
> but I would like to find a way to have
> -re [--resolution] arg
> -rl [--raster-level] arg
> Point is, I have some options that start with the same letter, so being
> able to make short abbreivations or acronyms for them would be helpful.
> If this is possible, it isn't real clear to me how, and I haven't turned
> up much in google.
> Any suggestions?
> Thanks!
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at