Subject: Re: [Boost-bugs] [Boost C++ Libraries] #545: Proogram_options: Fails to parse options with a common root
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-06-22 13:11:23
#545: Proogram_options: Fails to parse options with a common root
---------------------+------------------------------------------------------
Reporter: rleigh | Owner: vladimir_prus
Type: Bugs | Status: closed
Milestone: | Component: None
Version: None | Severity: Problem
Resolution: Fixed | Keywords:
---------------------+------------------------------------------------------
Changes (by christian.blichmann@â¦):
* severity: => Problem
Comment:
As of Boost 1.43.0 this is still problematic, see the test case below:
#include <iostream>
#include <boost/program_options.hpp>
namespace po = boost::program_options;
int main(int argc, char *argv[])
{
try
{
bool all, all_chroots, all_sessions;
po::options_description chroot("Chroot selection");
chroot.add_options()
("flag", "Some boolean flag")
("flag2", "Another flag that gets matched approximately");
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, chroot), vm);
po::notify(vm);
std::cout << "flag: " << vm.count("flag") << std::endl;
std::cout << "flag2: " << vm.count("flag2") << std::endl;
return 0;
}
catch (std::exception const& e)
{
std::cerr << e.what() << std::endl;
return 1;
}
}
Results:
$ g++ -o po-test po-test.cpp -lboost_program_options
$ ./po-test --flag
flag: 0
flag2: 1
$ ./po-test --flag2
flag: 0
flag2: 1
$ ./po-test --flag --flag2
multiple occurrences
Expected results (after applying program_options.patch):
$ ./po-test --flag
flag: 1
flag2: 0
$ ./po-test --flag2
flag: 0
flag2: 1
$ ./po-test --flag --flag2
flag: 1
flag2: 1
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/545#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC