diff --git a/src/CLI.cpp b/src/CLI.cpp index bf1fb15b1..921db892d 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -54,13 +54,41 @@ void CLI::entity (const std::string& name, const std::string& value) } //////////////////////////////////////////////////////////////////////////////// -// Capture the original, intact command line arguments. These will not be -// modified. +// Capture the original, intact command line arguments. void CLI::initialize (int argc, const char** argv) { _program = argv[0]; for (int i = 1; i < argc; ++i) _args.push_back (argv[i]); + + extractOverrides (); +} + +//////////////////////////////////////////////////////////////////////////////// +void CLI::extractOverrides () +{ + std::vector reconstructed; + + std::vector ::iterator i; + for (i = _args.begin (); i != _args.end (); ++i) + { + if (i->find ("rc:") == 0) + { + _rc = i->substr (3); + } + else if (i->find ("rc.") == 0) + { + std::string::size_type sep = arg.find ('=', 3); + if (sep == std::string::npos) + sep = arg.find (':', 3); + if (sep != std::string::npos) + _overrides[i->substr (3, sep - 3)] = i->substr (sep + 1); + } + else + reconstructed.push_back (*i); + } + + _args = reconstructed; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/CLI.h b/src/CLI.h index d743d0e5f..f07379d1a 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -40,12 +40,15 @@ public: void initialize (int, const char**); private: + void extractOverrides (); -private: +public: std::multimap _entities; std::map _aliases; std::string _program; std::vector _args; + std::string _rc; + std::map _overrides; }; #endif