Opened 13 years ago

Last modified 13 years ago

#3733 new Feature Requests

Detect platform to choose the conventional option for help

Reported by: hicham@… Owned by: Vladimir Prus
Milestone: Component: program_options
Version: Boost 1.41.0 Severity: Cosmetic
Keywords: Cc: s.ochsenknecht@…

Description

on POSIX, the --help option is typically used for printing usage information. on Windows, the /? is the typical option for that.

It would be cleaner if the user could check with some function whether the <help option> is set or not instead of explicitly checking for the "help" string

   if (vm.count("help"))

to decide when to print usage information.

Change History (1)

comment:1 by Sascha Ochsenknecht, 13 years ago

Cc: s.ochsenknecht@… added

I usually define a mapping table to map my command line options to the string value, e.g.:

enum MyOptions {
   HELP = 0,
   VERSION,
   INPUT
};
string options[] =  { "help", "version", "input" };


... /// usage
if (vm.count(options[HELP]))

Within my code I then use only the enum type. Errors are then detect during compile time.

You can define this options[] array for each platform you want to support and were it is different to the 'reference' array.

I sgguest to keep this type of mapping in the client code. Currently there is no 'special' handling for any options, all handled in the same way and I would like to keep this behaviour.

My suggestion is to set on "wont fix".

Thanks, Sascha

Note: See TracTickets for help on using tickets.