You should remove allow_unregistered()
from your parse command. You command should simply be
po::store(parse_command_line(argc, argv, desc), vm);
then exception will be thrown on unknown options.
http://www.boost.org/doc/libs/1_54_0/doc/html/program_options/howto.html#idp123440592
If you want exception/error, if option has no "--" you should write extra parser, something like this, can help you
std::pair<std::string, std::string> fix_option(const std::string& value)
{
std::string name = value;
std::string val;
std::string::size_type pos = name.find("=");
if (pos != std::string::npos)
{
val = name.substr(pos + 1);
name = name.substr(0, pos);
}
if (name.substr(0, 2) != "--")
{
throw std::logic_error(std::string("invalid command, no -- in command: ") + name);
}
return std::make_pair(name.substr(2), val);
}
results:
./new --help=j
output: j
./new help=j
output:
terminate called after throwing an instance of 'std::logic_error'
what(): invalid command, no -- in command: help