cmbi / mrs

Maarten's Retrieval Service
Boost Software License 1.0
0 stars 3 forks source link

Make argument parser more robust #6

Open jonblack opened 10 years ago

jonblack commented 10 years ago

The error displayed from the following invocation isn't correct. The mistake is that the option -c is part of the username.

./mrs server -u jon-c config/mrs-config.xml --command start

mrs exited with an exception:
option '--command' cannot be specified more than once
cbaakman commented 10 years ago

This error string is not in the mrs code itself. It's in boost::program_options::errors

This is how boost's commandline parser interprets the argument list.

Usually, mrs server is used like this:

./mrs server start

where 'start' is the first positional argument. MRS' source code specifies that the first positional option must be given the name '--command'. So it's interpreted by boost as:

./mrs server --command start

In your case, 'config/mrs-config.xml' is the first positional argument. Because there's also a second option with that with name '--command', with value start, boost sees the option '--command' specified twice and throws an error.