Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reason we're forcing the args to be lowercase? #15

Open
Swiley opened this issue Oct 14, 2016 · 1 comment
Open

Reason we're forcing the args to be lowercase? #15

Swiley opened this issue Oct 14, 2016 · 1 comment
Labels

Comments

@Swiley
Copy link
Contributor

Swiley commented Oct 14, 2016

Trying to understand why we're forcing the args lowercase here -

void SettingsManager::parseCommandLineArgs(const std::vector<std::string>& args) {
    for (auto arg : args) {
        int splitIndex = (int)arg.find_first_of("=");
        if (splitIndex != std::string::npos) {
            **std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower);**
            std::string key = arg.substr(0, splitIndex);
            std::string value = arg.substr(splitIndex + 1, arg.size() - splitIndex - 1);

            auto callbackListIt = mCommandLineArgsHandlers.find(key);
            if (callbackListIt == mCommandLineArgsHandlers.end()) 
                continue;

            for (auto callback : callbackListIt->second) {
                callback(value);
            }
        }
    }
}

Got tripped up on creating my own arg, debugHasAttract=false. When I added to parser I forgot to lowercase it, so this won't find a match
SettingsManager::getInstance()->addCommandLineParser("debugHasAttract", [.....
but this will
SettingsManager::getInstance()->addCommandLineParser("debughasattract", [.....

As I'm looking at it a reason isn't jumping out at me, just curious

@benjaminbojko
Copy link
Collaborator

I feel like there a reason initially, but at this point I don't see a fundamental reason for it. Could arguably take it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants