X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=command.hpp;h=37186529ab1f75e5747138d74f976c5df3c1bbe9;hp=2ba35ab14308ded53d6868586d8695799cbb25a0;hb=615301e57c25e241356a9c2380648d117709458d;hpb=1a5c2356c1b955c6ec024b2baf9f46377ee7c72e diff --git a/command.hpp b/command.hpp index 2ba35ab..3718652 100644 --- a/command.hpp +++ b/command.hpp @@ -3,7 +3,7 @@ //test2 /* * command.h - * + * nast * * Created by Pat Schloss on 10/23/08. * Copyright 2008 Patrick D. Schloss. All rights reserved. @@ -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; @@ -74,8 +82,13 @@ class Command { m->mothurOut("[ERROR]: Did not provide variable for " + pieces[i] + ".\n"); m->control_pressed = true; }else { if (it->second != "") { - if (it->first != "[filename]") { filename += it->second + "."; } - else { filename += it->second; } + if (it->first == "[filename]") { filename += it->second; } + else if (it->first == "[extension]") { + if (filename.length() > 0) { //rip off last "." + filename = filename.substr(0, filename.length()-1); + } + filename += it->second + "."; + }else { filename += it->second + "."; } } } }else {