Support for multi-digit test indices

master
Benjamin Kraft 2 years ago
parent 95361c61e0
commit 874254c1b6
  1. 18
      src/main.cpp

@ -56,6 +56,17 @@ string getSessionKey() {
return key; return key;
} }
void parseArgument(const string& arg, int &dayNum, bool &useTestInput, int &testFetchIndex){
size_t tIndex = arg.find('T');
if (tIndex == string::npos) {
dayNum = stoi(arg);
return;
}
dayNum = stoi(arg.substr(0, tIndex));
useTestInput = true;
testFetchIndex = stoi(arg.substr(tIndex + 1));
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
auto key = getSessionKey(); auto key = getSessionKey();
@ -64,9 +75,10 @@ int main(int argc, char *argv[]) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
string arg = argv[i]; string arg = argv[i];
bool useTestInput = arg.size() > 1 && arg[1] == 'T'; bool useTestInput = false;
int testFetchIndex = useTestInput && arg.size() > 2 ? arg[2] - '0' : 0; int testFetchIndex;
int dayNum = std::stoi(arg); int dayNum;
parseArgument(arg, dayNum, useTestInput, testFetchIndex);
cout << "Running day " << dayNum << endl; cout << "Running day " << dayNum << endl;
Input input = getInput(dayNum, key, useTestInput, testFetchIndex); Input input = getInput(dayNum, key, useTestInput, testFetchIndex);
Day *day = days[dayNum - 1]; Day *day = days[dayNum - 1];

Loading…
Cancel
Save