Comment 7 for bug 1226227

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

In principle I don't think it is a good idea to ignore unrecognised arguments on the command line - that only leads to confusion when users misspell something. Having two separate parts of the program parsing them is the real problem Mir was coded on the misguided assumption that boost.Options was good enough for all client code.

I think a better solution would be to decouple the creation of the options object from the initialisation of DefaultServerConfiguration. That way options can be passed directly to DefaultServerConfiguration without any reference to the command line. Clearly we'd continue to provide a default option parser. (Maybe this could return the arguments it doesn't interpret?)

There is a precedent for manipulating the "arguments" to get around this - the following comes from the Mir test framework:

int main(int argc, char** argv)
{
    ::argc = std::remove_if(
        argv,
        argv+argc,
        [](char const* arg) { return !strncmp(arg, "--gtest_", 8); }) - argv;
    ::argv = const_cast<char const**>(argv);

  ::testing::InitGoogleTest(&argc, argv);

  return RUN_ALL_TESTS();
}