Question

J'utilise boost :: program_options comme ceci:

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)./*positional(pd).*/run(), vm);

Si je passe le paramètre de ligne de commande -I hithere cela fonctionne, mais je passe boost /I hithere jette un boost::bad_any_cast avec un what() de "conversion a échoué en utilisant boost :: any_cast".

Est-il possible d'utiliser program_options pour analyser soit /-delimitted ou --delimitted options? Question bonus, il peut être configuré de telle sorte que / et - définir la même option, mais sont opposés binaires de l'autre? Par exemple, /verbose pourrait signifier une journalisation tout -verbose pourrait signifier moins verbeux exploitation forestière.

Était-ce utile?
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top