I use boost :: program_options as follows:
namespace po = boost::program_options; po::options_description desc("Options"); desc.add_options() ("help,?", "Show Options") ("capture-file,I", po::value<string>(), "Capture File") ("capture-format,F", po::value<string>()->default_value("pcap"), "Capture File Format") ("output-file,O", po::value<string>()->default_value("CONOUT$"), "Output File"); po::variables_map vm; po::store(po::command_line_parser(ac, av).options(desc).run(), vm);
If I pass the -I hithere command-line -I hithere , it works, but I pass /I hithere boost, throws a boost::bad_any_cast with what() from "failed conversion using boost :: any_cast".
Can I use program_options to parse the / -delimitted or - -delimitted options? The bonus question is, can it be configured so that / and - set the same option, but are binary opposites from each other? For example, /verbose may mean verbose logging, and -verbose may mean less verbose logging.
c ++ boost-program-options
John dibling
source share