Fix the previous commit by adding an outputFile string.

This commit is contained in:
Username404-59 2021-06-10 17:25:59 +02:00
parent c5d33fd480
commit af729c527b
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 7 additions and 4 deletions

View File

@ -17,17 +17,20 @@ int main(int argc, char* argv[]) {
if ((currentArg == "--printresult") || (currentArg == "-p")) printResult = true; if ((currentArg == "--printresult") || (currentArg == "-p")) printResult = true;
else if (currentArg.starts_with("--target=")) { else if (currentArg.starts_with("--target=")) {
currentArg.remove_prefix(9); currentArg.remove_prefix(9);
target = currentArg; target = '.';
target += currentArg;
} }
else files.push_back(currentArg); else if (currentArg.ends_with(".ybcon")) files.push_back(currentArg);
} }
const set<string_view> uniqueFiles(files.begin(), files.end()); const set<string_view> uniqueFiles(files.begin(), files.end());
for (string_view fileName: uniqueFiles) { for (string_view fileName: uniqueFiles) {
if (fileName != "none" and fileName.ends_with(".ybcon")) { if (fileName != "none") {
const string transpiledString = transpile(parseString(getFileContent(fileName.data())), target); const string transpiledString = transpile(parseString(getFileContent(fileName.data())), target);
if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n" << "[WIP]\n" << transpiledString << "\n\n"; if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n" << "[WIP]\n" << transpiledString << "\n\n";
fileName.remove_suffix(6); fileName.remove_suffix(6);
outputFileContent(target.insert(0, fileName), transpiledString); string outputFile;
outputFile.append(fileName); outputFile.append(target);
outputFileContent(outputFile, transpiledString);
} }
} }
} else cout << "No valid file provided.\n"; } else cout << "No valid file provided.\n";