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
parent
74e8427f89
commit
6435f9be39
25
src/ceev.cc
25
src/ceev.cc
|
@ -62,16 +62,18 @@ int create_fs(std::deque<std::string> args) {
|
|||
std::cout << "Project name [" << directory << "]: ";
|
||||
std::getline(std::cin, project_name);
|
||||
if (project_name == "") project_name = directory;
|
||||
config << "name = " << project_name << '\n';
|
||||
config << "name=" << project_name << '\n';
|
||||
std::string version;
|
||||
std::cout << "Version [0.0.1]: ";
|
||||
std::getline(std::cin, version);
|
||||
if (version == "") version = "0.0.1";
|
||||
config << "version = " << version << '\n';
|
||||
config << "version=" << version << '\n';
|
||||
std::string author;
|
||||
std::cout << "Author: ";
|
||||
std::getline(std::cin, author);
|
||||
if (author == "") author = "Unknown";
|
||||
config << "author=" << author << '\n';
|
||||
config.close();
|
||||
return 0;
|
||||
}
|
||||
int build_project(std::deque<std::string> args) {
|
||||
|
@ -79,6 +81,25 @@ int build_project(std::deque<std::string> args) {
|
|||
return 0;
|
||||
}
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
struct config_data {
|
||||
std::string name = "";
|
||||
std::string version = "";
|
||||
std::string author = "";
|
||||
};
|
||||
int usage();
|
||||
int show_help();
|
||||
int create_fs(std::deque<std::string> args);
|
||||
|
|
Loading…
Reference in New Issue