I am using Boost 1.33.0 and MS Visual Studio .NET 2003
(13.10.3077) and having trouble developing a simple
Win32 console application that accepts case-insensitive
command-line options.
-- output ----------------------------------
..\>app -n 2
BOOST_PROGRAM_OPTIONS_VERSION=2
count set to 2
..\>app -N 2
BOOST_PROGRAM_OPTIONS_VERSION=2
Exception caught: unknown option -N
--------------------------------------------
-- code ------------------------------------
#include
int _tmain(int argc, _TCHAR* argv[])
{
using std::cout;
using std::endl;
namespace po = boost::program_options;
namespace cls = boost::program_options::command_line_style;
int count = 0;
cout << "BOOST_PROGRAM_OPTIONS_VERSION=" << BOOST_PROGRAM_OPTIONS_VERSION << endl;
try
{
po::options_description desc("Usage");
desc.add_options()
("help,h", "produce help message")
("count,n", po::value<int>(&count), "repeat count")
;
po::variables_map vm;
int cl_style = 0;
cl_style |= cls::allow_short;
cl_style |= cls::allow_dash_for_short;
cl_style |= cls::short_allow_next;
cl_style |= cls::case_insensitive;
po::store(po::command_line_parser(argc, argv).options(desc).style(cl_style).run(), vm);
po::notify(vm);
if (vm.count("count"))
cout << "count set to " << count << endl;
else
cout << "count not set" << endl;
}
catch( exception &e )
{
cout << "Exception caught:\t" << e.what() << endl;
}
catch(...)
{
cout << "Unhandled exception caught!" << endl;
}
}
--------------------------------------------
The line "cl_style |= cls::case_insensitive;" seems to
have no effect. The other options in that section do
seem to work as I can create other errors by omitting
others. I tried for a minimal set of styles.
Any ideas what I'm doing wrong?
Thanks.
Brian Lawry
Mfg Software Engineer
Compressor Controls Corp
blawrycccglobal.com