X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=command.hpp;h=48dcf283c8874c8168ac6cf48748bf80851caef3;hb=567e4bca5d62bd8ea316ce5def320d070d7507b8;hp=7ed03f161e18b9ea5bd8374606585ccefb41772e;hpb=ac4d6a2ac10c8feb043aa11582a769b6093c5941;p=mothur.git diff --git a/command.hpp b/command.hpp index 7ed03f1..48dcf28 100644 --- a/command.hpp +++ b/command.hpp @@ -50,14 +50,22 @@ class Command { //find pattern to use based on number of variables passed in string pattern = ""; bool foundPattern = false; + vector numVariablesPerPattern; for (int i = 0; i < patterns.size(); i++) { int numVariables = 0; for (int j = 0; j < patterns[i].length(); j++) { if (patterns[i][j] == '[') { numVariables++; } } + numVariablesPerPattern.push_back(numVariables); if (numVariables == variableParts.size()) { pattern = patterns[i]; foundPattern = true; break; } } - if (!foundPattern) { m->mothurOut("[ERROR]: Not enough variable pieces for " + type + ".\n"); m->control_pressed = true; } + //if you didn't find an exact match do we have something that might work + if (!foundPattern) { + for (int i = 0; i < numVariablesPerPattern.size(); i++) { + if (numVariablesPerPattern[i] < variableParts.size()) { pattern = patterns[i]; foundPattern = true; break; } + } + if (!foundPattern) { m->mothurOut("[ERROR]: Not enough variable pieces for " + type + ".\n"); m->control_pressed = true; } + } if (pattern != "") { int numVariables = 0;