Started functionality on run_project()

It reads and extracts the config for now.
The plan for the actual files are yet to be made.
Yes, the *plan* hasn't been made yet. Don't remind me.
master
Ruben 2022-12-21 15:30:27 +01:00
parent 74e8427f89
commit 6435f9be39
No known key found for this signature in database
GPG Key ID: F6DAAC2742760162
2 changed files with 28 additions and 2 deletions

View File

@ -72,6 +72,8 @@ int create_fs(std::deque<std::string> args) {
std::cout << "Author: "; std::cout << "Author: ";
std::getline(std::cin, author); std::getline(std::cin, author);
if (author == "") author = "Unknown"; if (author == "") author = "Unknown";
config << "author=" << author << '\n';
config.close();
return 0; return 0;
} }
int build_project(std::deque<std::string> args) { int build_project(std::deque<std::string> args) {
@ -79,6 +81,25 @@ int build_project(std::deque<std::string> args) {
return 0; return 0;
} }
int run_project(std::deque<std::string> args) { int run_project(std::deque<std::string> args) {
std::ifstream config(".ceev/config");
if (!config) {
std::cerr << bg_red(bold("ERROR")) << ": Could not open config\n";
std::cerr << "Run `ceev init' to create a new project." << std::endl;
return 1;
}
std::string line;
while (std::getline(config, line)) {
std::istringstream iss(line);
struct config_data data;
std::string key;
if (!std::getline(iss, key, '=')) continue;
std::string value;
if (!std::getline(iss, value)) continue;
if (key == "name") data.name = value;
if (key == "version") data.version = value;
if (key == "author") data.author = value;
}
config.close();
std::cout << "Running project..." << std::endl; std::cout << "Running project..." << std::endl;
return 0; return 0;
} }

View File

@ -11,6 +11,11 @@
namespace fs = std::filesystem; namespace fs = std::filesystem;
struct config_data {
std::string name = "";
std::string version = "";
std::string author = "";
};
int usage(); int usage();
int show_help(); int show_help();
int create_fs(std::deque<std::string> args); int create_fs(std::deque<std::string> args);