Add README, LICENSE. Update code

This commit is contained in:
2025-04-11 18:04:57 +10:00
parent ac17ed2067
commit f39dd71943
4 changed files with 808 additions and 0 deletions

View File

@@ -49,6 +49,63 @@ int main(int argc, char* argv[]) {
return 0;
} else if (currentArg == "--debug") {
isDebug = true;
} else if (currentArg == "--init") {
string dir = filesystem::current_path().filename().string();
string lang;
bool loop = true;
if (!filesystem::is_empty(filesystem::current_path())) {
error("Please initialise your project in an empty directory");
return 1;
}
while (loop) {
cout << "Choose a language for your project" << endl;
cout << "1. C" << endl;
cout << "2. C++" << endl;
cout << "Please enter the corresponding number." << endl;
cout << "Choice: ";
getline(cin, lang);
if (lang == "1") {
// C making stuff
loop = false;
} else if (lang == "2") {
// C++ making stuff
loop = false;
} else {
error("Please choose a valid option");
}
}
cout << "Choose a name for your project (leave blank to use directory name): ";
string buffer;
getline(cin, buffer);
if (!buffer.empty()) {
dir = buffer;
}
debug("Creating new project with name " + dir + " and language ID " + lang);
ofstream bobfile("Bobfile");
string compiler;
string language;
if (lang == "1") {
compiler = "gcc";
language = "c";
} else if (lang == "2") {
compiler = "g++";
language = "cpp";
}
bobfile << "compiler \"" + compiler + "\";\nbinary \"" + dir + "\";\nsource \"src/main." + language + "\";\ncompile;\n";
bobfile.close();
debug("Created Bobfile");
filesystem::path srcDir = "src";
filesystem::create_directory(srcDir);
debug("Created source directory");
ofstream srcFile("src/main." + language);
if (lang == "1") {
srcFile << "#include <stdio.h>\nint main() {\nprintf(\"Hello, World!\\n\");\nreturn 0;\n}\n";
} else if (lang == "2") {
srcFile << "#include <iostream>\nusing namespace std;\nint main() {\ncout << \"Hello, World!\" << endl;\nreturn 0;\n}\n";
}
srcFile.close();
debug("Created source file");
return 0;
} else if (currentArg.substr(0,2) == "--") {
error("Argument " + currentArg + " not understood");
return 1;