Started work on the SDL prototype
parent
1b38bd9678
commit
471d83718f
505
src/ceev.cc
505
src/ceev.cc
|
@ -1,62 +1,70 @@
|
||||||
#include "ceev.h"
|
#include "ceev.h"
|
||||||
|
|
||||||
int usage() {
|
int usage() {
|
||||||
std::cout << "Usage:";
|
std::cout << "Usage:";
|
||||||
std::cout << "\n\t";
|
std::cout << "\n\t";
|
||||||
std::cout << GET_PROGRAM_NAME() << " [" << cyan("command") << "] <" << bright_green("options") << ">\n";
|
std::cout << GET_PROGRAM_NAME() << " [" << cyan("command") << "] <"
|
||||||
std::cout << "\n";
|
<< bright_green("options") << ">\n";
|
||||||
std::cout << "Run `" << GET_PROGRAM_NAME() << bright_green(" --help") << "' for more information.\n" << std::endl;
|
std::cout << "\n";
|
||||||
return 1;
|
std::cout << "Run `" << GET_PROGRAM_NAME() << bright_green(" --help")
|
||||||
|
<< "' for more information.\n"
|
||||||
|
<< std::endl;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int show_help() {
|
int show_help() {
|
||||||
std::cout << GET_PROGRAM_NAME() << " [" << cyan("command") << "] <" << bright_green("options") << ">\n";
|
std::cout << GET_PROGRAM_NAME() << " [" << cyan("command") << "] <"
|
||||||
std::cout << "\n";
|
<< bright_green("options") << ">\n";
|
||||||
std::cout << "Usage:";
|
std::cout << "\n";
|
||||||
// ceev init
|
std::cout << "Usage:";
|
||||||
std::cout << "\n*\t";
|
// ceev init
|
||||||
std::cout << GET_PROGRAM_NAME() << cyan(" init ") << "<" << bright_green("--force") << ">\n";
|
std::cout << "\n*\t";
|
||||||
std::cout << "\t\t";
|
std::cout << GET_PROGRAM_NAME() << cyan(" init ") << "<"
|
||||||
std::cout << "Creates the CeeV file system. Can only be used ";
|
<< bright_green("--force") << ">\n";
|
||||||
std::cout << "if the current folder is empty,";
|
std::cout << "\t\t";
|
||||||
std::cout << "\n\t\tor when run with `" << bright_green("--force") << "'";
|
std::cout << "Creates the CeeV file system. Can only be used ";
|
||||||
// ceev build
|
std::cout << "if the current folder is empty,";
|
||||||
std::cout << "\n*\t";
|
std::cout << "\n\t\tor when run with `" << bright_green("--force") << "'";
|
||||||
std::cout << GET_PROGRAM_NAME() << cyan(" build") << "\n";
|
// ceev build
|
||||||
std::cout << "\t\t";
|
std::cout << "\n*\t";
|
||||||
std::cout << "Not yet implemented";
|
std::cout << GET_PROGRAM_NAME() << cyan(" build") << "\n";
|
||||||
// ceev run
|
std::cout << "\t\t";
|
||||||
std::cout << "\n*\t";
|
std::cout << "Not yet implemented";
|
||||||
std::cout << GET_PROGRAM_NAME() << cyan(" run") << "\n";
|
// ceev run
|
||||||
std::cout << "\t\t";
|
std::cout << "\n*\t";
|
||||||
std::cout << "Not yet implemented";
|
std::cout << GET_PROGRAM_NAME() << cyan(" run") << "\n";
|
||||||
// ceev clean
|
std::cout << "\t\t";
|
||||||
std::cout << "\n*\t";
|
std::cout << "Not yet implemented";
|
||||||
std::cout << GET_PROGRAM_NAME() << cyan(" clean") << "\n";
|
// ceev clean
|
||||||
std::cout << "\t\t";
|
std::cout << "\n*\t";
|
||||||
std::cout << "Not yet implemented";
|
std::cout << GET_PROGRAM_NAME() << cyan(" clean") << "\n";
|
||||||
// ceev devel
|
std::cout << "\t\t";
|
||||||
std::cout << "\n*\t";
|
std::cout << "Not yet implemented";
|
||||||
std::cout << GET_PROGRAM_NAME() << cyan(" devel ") << "<" << bright_green("--help") << ">\n";
|
// ceev devel
|
||||||
std::cout << "\t\t";
|
std::cout << "\n*\t";
|
||||||
std::cout << "Supplementary command for development information";
|
std::cout << GET_PROGRAM_NAME() << cyan(" devel ") << "<"
|
||||||
// ceev --help
|
<< bright_green("--help") << ">\n";
|
||||||
std::cout << "\n*\t";
|
std::cout << "\t\t";
|
||||||
std::cout << GET_PROGRAM_NAME() << cyan(" --help") << "/" << cyan("-h") << "\n";
|
std::cout << "Supplementary command for development information";
|
||||||
std::cout << "\t\t";
|
// ceev --help
|
||||||
std::cout << "This help page.";
|
std::cout << "\n*\t";
|
||||||
// ceev --version
|
std::cout << GET_PROGRAM_NAME() << cyan(" --help") << "/" << cyan("-h")
|
||||||
std::cout << "\n*\t";
|
<< "\n";
|
||||||
std::cout << GET_PROGRAM_NAME() << cyan(" --version") << "/" << cyan("-v") << "\n";
|
std::cout << "\t\t";
|
||||||
std::cout << "\t\t";
|
std::cout << "This help page.";
|
||||||
std::cout << "Get the current version.";
|
// ceev --version
|
||||||
std::cout << std::endl;
|
std::cout << "\n*\t";
|
||||||
return 0;
|
std::cout << GET_PROGRAM_NAME() << cyan(" --version") << "/" << cyan("-v")
|
||||||
|
<< "\n";
|
||||||
|
std::cout << "\t\t";
|
||||||
|
std::cout << "Get the current version.";
|
||||||
|
std::cout << std::endl;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int show_version() {
|
int show_version() {
|
||||||
std::cout << "CeeV version " << __ceev_version << '\n';
|
std::cout << "CeeV version " << __ceev_version << '\n';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool replace(std::string& str, const std::string& from, const std::string& to) {
|
bool replace(std::string& str, const std::string& from, const std::string& to) {
|
||||||
|
@ -68,164 +76,275 @@ bool replace(std::string& str, const std::string& from, const std::string& to) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string query_author() {
|
static std::string query_author() {
|
||||||
std::string author;
|
std::string author;
|
||||||
std::cout << "Author: ";
|
std::cout << "Author: ";
|
||||||
std::getline(std::cin, author);
|
std::getline(std::cin, author);
|
||||||
return author;
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct config_data get_config() {
|
||||||
|
fs::path config_path = fs::current_path();
|
||||||
|
std::string line;
|
||||||
|
struct config_data data;
|
||||||
|
std::ifstream config(config_path / ".ceev" / CONFIG_FILENAME);
|
||||||
|
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 data;
|
||||||
|
}
|
||||||
|
while (std::getline(config, line)) {
|
||||||
|
std::istringstream iss(line);
|
||||||
|
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;
|
||||||
|
if (key == "email")
|
||||||
|
data.email = value;
|
||||||
|
}
|
||||||
|
config.close();
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
int create_fs(std::deque<std::string> args) {
|
int create_fs(std::deque<std::string> args) {
|
||||||
fs::path cwd = fs::current_path();
|
fs::path cwd = fs::current_path();
|
||||||
if (!fs::is_empty(cwd) && ((!args.empty() && args[0] != "--force") || args.empty())) {
|
if (!fs::is_empty(cwd) &&
|
||||||
std::cerr << bg_red(bold("ERROR")) << ": Folder not empty.\n" <<
|
((!args.empty() && args[0] != "--force") || args.empty())) {
|
||||||
"Run the command with `--force' to run anyways" << std::endl;
|
std::cerr << bg_red(bold("ERROR")) << ": Folder not empty.\n"
|
||||||
return 1;
|
<< "Run the command with `--force' to run anyways" << std::endl;
|
||||||
}
|
return 1;
|
||||||
fs::create_directory(cwd.string() + "/.ceev", cwd);
|
}
|
||||||
fs::create_directory(cwd.string() + "/src", cwd);
|
fs::create_directory(cwd / ".ceev", cwd);
|
||||||
std::ofstream config(cwd.string() + "/.ceev/" + CONFIG_FILENAME);
|
fs::create_directory(cwd / "src", cwd);
|
||||||
std::string directory = cwd.string().substr(cwd.parent_path().string().length() + 1);
|
std::ofstream config(cwd / ".ceev/" / CONFIG_FILENAME);
|
||||||
std::cout << "Initializing project...\n";
|
std::string directory =
|
||||||
std::cout << "You can change this information later by editing .ceev/" << CONFIG_FILENAME << "\n";
|
cwd.string().substr(cwd.parent_path().string().length() + 1);
|
||||||
std::string project_name;
|
std::cout << "Initializing project...\n";
|
||||||
std::cout << "Project name [" << directory << "]: ";
|
std::cout << "You can change this information later by editing .ceev/"
|
||||||
std::getline(std::cin, project_name);
|
<< CONFIG_FILENAME << "\n";
|
||||||
if (project_name == "") project_name = directory;
|
std::string project_name;
|
||||||
config << "name=" << project_name << '\n';
|
std::cout << "Project name [" << directory << "]: ";
|
||||||
std::string version;
|
std::getline(std::cin, project_name);
|
||||||
std::cout << "Version [0.0.1]: ";
|
if (project_name == "")
|
||||||
std::getline(std::cin, version);
|
project_name = directory;
|
||||||
if (version == "") version = "0.0.1";
|
config << "name=" << project_name << '\n';
|
||||||
config << "version=" << version << '\n';
|
std::string version;
|
||||||
std::string author = query_author();
|
std::cout << "Version [0.0.1]: ";
|
||||||
if (author == "") {
|
std::getline(std::cin, version);
|
||||||
std::cerr << bg_red(bold("ERROR")) << ": Author cannot be empty.\n";
|
if (version == "")
|
||||||
author = query_author();
|
version = "0.0.1";
|
||||||
}
|
config << "version=" << version << '\n';
|
||||||
config << "author=" << author << '\n';
|
std::string author = query_author();
|
||||||
std::string email;
|
if (author == "") {
|
||||||
while (author.find(' ') != std::string::npos)
|
std::cerr << bg_red(bold("ERROR")) << ": Author cannot be empty.\n";
|
||||||
replace(author, " ", ".");
|
author = query_author();
|
||||||
std::cout << "Email [" << author << "@example.org]: ";
|
}
|
||||||
std::getline(std::cin, email);
|
config << "author=" << author << '\n';
|
||||||
if (email == "") email = author + "@example.org";
|
std::string email;
|
||||||
config << "email=" << email << '\n';
|
while (author.find(' ') != std::string::npos)
|
||||||
config.close();
|
replace(author, " ", ".");
|
||||||
return 0;
|
std::cout << "Email [" << author << "@example.org]: ";
|
||||||
|
std::getline(std::cin, email);
|
||||||
|
if (email == "")
|
||||||
|
email = author + "@example.org";
|
||||||
|
config << "email=" << email << '\n';
|
||||||
|
config.close();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
int build_project(std::deque<std::string> args) {
|
int build_project(std::deque<std::string> args) {
|
||||||
std::cout << "Building project..." << std::endl;
|
std::cout << "Building project..." << std::endl;
|
||||||
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");
|
struct config_data data = get_config();
|
||||||
if (!config) {
|
std::cout << "Name: " << data.name << '\n';
|
||||||
std::cerr << bg_red(bold("ERROR")) << ": Could not open config\n";
|
std::cout << "Version: " << data.version << '\n';
|
||||||
std::cerr << "Run `ceev init' to create a new project." << std::endl;
|
std::cout << "Author: " << data.author << '\n';
|
||||||
return 1;
|
std::cout << "Email: " << data.email << '\n';
|
||||||
}
|
std::cout << "Running project..." << std::endl;
|
||||||
std::string line;
|
return 0;
|
||||||
struct config_data data;
|
|
||||||
while (std::getline(config, line)) {
|
|
||||||
std::istringstream iss(line);
|
|
||||||
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;
|
|
||||||
if (key == "email") data.email = value;
|
|
||||||
}
|
|
||||||
config.close();
|
|
||||||
std::cout << "Name: " << data.name << '\n';
|
|
||||||
std::cout << "Version: " << data.version << '\n';
|
|
||||||
std::cout << "Author: " << data.author << '\n';
|
|
||||||
std::cout << "Email: " << data.email << '\n';
|
|
||||||
std::cout << "Running project..." << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
int clean_project(std::deque<std::string> args) {
|
int clean_project(std::deque<std::string> args) {
|
||||||
std::cout << "Cleaning project..." << std::endl;
|
std::cout << "Cleaning project..." << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int devel(std::deque<std::string> args) {
|
int devel(std::deque<std::string> args) {
|
||||||
if (args.empty()) {
|
if (args.empty()) {
|
||||||
std::cout << bg_red(bold("ERROR")) << ": No subcommands given." << std::endl;
|
std::cout << bg_red(bold("ERROR")) << ": No subcommands given."
|
||||||
devel_help();
|
<< std::endl;
|
||||||
return 1;
|
devel_help();
|
||||||
}
|
return 1;
|
||||||
std::string a1 = args[0];
|
}
|
||||||
args.pop_front();
|
std::string a1 = args[0];
|
||||||
if (a1 == "commitinfo") return devel_commitinfo();
|
args.pop_front();
|
||||||
std::string kw;
|
if (a1 == "commitinfo")
|
||||||
if (a1.substr(0, 2) == "--") {
|
return devel_commitinfo();
|
||||||
kw = a1.substr(2);
|
if (a1 == "roadmap")
|
||||||
if (kw == "help") return devel_help();
|
return devel_roadmap();
|
||||||
}
|
if (a1 == "sdl2")
|
||||||
if (a1.substr(0, 1) == "-") {
|
return devel_sdl2(args);
|
||||||
kw = a1.substr(1);
|
|
||||||
if (kw == "h") return devel_help();
|
std::string kw;
|
||||||
}
|
if (a1.substr(0, 2) == "--") {
|
||||||
std::cerr << bg_red(bold("ERROR")) << ": Unknown command `" << bright_magenta(a1) << "'\n" << std::endl;
|
kw = a1.substr(2);
|
||||||
devel_help();
|
if (kw == "help")
|
||||||
return 1;
|
return devel_help();
|
||||||
|
}
|
||||||
|
if (a1.substr(0, 1) == "-") {
|
||||||
|
kw = a1.substr(1);
|
||||||
|
if (kw == "h")
|
||||||
|
return devel_help();
|
||||||
|
}
|
||||||
|
std::cerr << bg_red(bold("ERROR")) << ": Unknown command `"
|
||||||
|
<< bright_magenta(a1) << "'\n"
|
||||||
|
<< std::endl;
|
||||||
|
devel_help();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
int devel_help() {
|
int devel_help() {
|
||||||
std::cout << "Usage:\n";
|
std::cout << "Usage:";
|
||||||
// ceev devel roadmap
|
// ceev devel roadmap
|
||||||
std::cout << "\n*\t";
|
std::cout << "\n*\t";
|
||||||
std::cout << GET_PROGRAM_NAME() << " devel " << cyan("roadmap") << "\n";
|
std::cout << GET_PROGRAM_NAME() << " devel " << cyan("roadmap") << "\n";
|
||||||
std::cout << "\t\t";
|
std::cout << "\t\t";
|
||||||
std::cout << "Get the current roadmap.\n";
|
std::cout << "Get the current roadmap.";
|
||||||
// ceev devel commitinfo
|
// ceev devel commitinfo
|
||||||
std::cout << "\n*\t";
|
std::cout << "\n*\t";
|
||||||
std::cout << GET_PROGRAM_NAME() << " devel " << cyan("commitinfo") << "\n";
|
std::cout << GET_PROGRAM_NAME() << " devel " << cyan("commitinfo") << "\n";
|
||||||
std::cout << "\t\t";
|
std::cout << "\t\t";
|
||||||
std::cout << "Get info about the latest commit.\n";
|
std::cout << "Get info about the latest commit.";
|
||||||
// ceev devel --help
|
// ceev devel sdl2
|
||||||
std::cout << "\n*\t";
|
std::cout << "\n*\t";
|
||||||
std::cout << GET_PROGRAM_NAME() << " devel " << cyan("--help") << "/" << cyan("-h") << "\n";
|
std::cout << GET_PROGRAM_NAME() << " devel " << cyan("sdl2") << "\n";
|
||||||
std::cout << "\t\t";
|
std::cout << "\t\t";
|
||||||
std::cout << "This help page.\n";
|
std::cout << "Tests of SDL2";
|
||||||
return 0;
|
// ceev devel --help
|
||||||
|
std::cout << "\n*\t";
|
||||||
|
std::cout << GET_PROGRAM_NAME() << " devel " << cyan("--help") << "/"
|
||||||
|
<< cyan("-h") << "\n";
|
||||||
|
std::cout << "\t\t";
|
||||||
|
std::cout << "This help page.";
|
||||||
|
std::cout << std::endl;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
int devel_commitinfo() {
|
int devel_commitinfo() {
|
||||||
std::cout << "CeeV build " << bright_cyan(bold(GIT_COMMIT_HASH)) << "\n\n";
|
std::cout << "CeeV build " << bright_cyan(bold(GIT_COMMIT_HASH)) << "\n\n";
|
||||||
std::cout << "Commit message:\n";
|
std::cout << "Commit message:\n";
|
||||||
std::cout << bright_cyan(bold(GIT_COMMIT_MSG)) << std::endl;
|
std::cout << bright_cyan(bold(GIT_COMMIT_MSG)) << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
int devel_roadmap() {
|
||||||
|
std::cout << "CeeV roadmap:\n";
|
||||||
|
std::cout << "*" << bg_bright_green("INPROG")
|
||||||
|
<< ":\tGet a working SDL prototype.\n";
|
||||||
|
std::cout << "*" << bg_yellow(green("TODO"))
|
||||||
|
<< " :\tMake a language parser.\n";
|
||||||
|
std::cout << "*" << bg_yellow(green("TODO"))
|
||||||
|
<< " :\tMake a language compiler.\n";
|
||||||
|
std::cout << "*" << bg_yellow(green("TODO")) << " :\tTest the language.\n";
|
||||||
|
std::cout << "*" << bg_green(bold("STATUS")) << ": ";
|
||||||
|
std::cout << "SDL is currently blocking, the rest depends on SDL to be in a "
|
||||||
|
"prototype stage, at least."
|
||||||
|
<< std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int devel_sdl2(std::deque<std::string> args) {
|
||||||
|
struct config_data data = get_config();
|
||||||
|
if (data.name == "" &&
|
||||||
|
(args.empty() || args[0] != "--use-defaults" || args[0] != "-D")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const int SCREEN_WIDTH = 640;
|
||||||
|
const int SCREEN_HEIGHT = 480;
|
||||||
|
SDL_Window *window = nullptr;
|
||||||
|
SDL_Surface *screen_surface = nullptr;
|
||||||
|
SDL_Surface *img_surface = nullptr;
|
||||||
|
return 0;
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
|
std::cerr << bg_red(bold("ERROR"))
|
||||||
|
<< ": SDL could not initialize! SDL_Error: " << SDL_GetError()
|
||||||
|
<< std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
window = SDL_CreateWindow(data.name.c_str(), SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH,
|
||||||
|
SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
|
||||||
|
if (window == nullptr) {
|
||||||
|
std::cerr << bg_red(bold("ERROR"))
|
||||||
|
<< ": Window could not be created! SDL_Error: " << SDL_GetError()
|
||||||
|
<< std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
screen_surface = SDL_GetWindowSurface(window);
|
||||||
|
SDL_FillRect(screen_surface, nullptr,
|
||||||
|
SDL_MapRGB(screen_surface->format, 0xFF, 0xFF, 0xFF));
|
||||||
|
screen_surface = SDL_GetWindowSurface(window);
|
||||||
|
SDL_FillRect(screen_surface, nullptr,
|
||||||
|
SDL_MapRGB(screen_surface->format, 0xFF, 0xFF, 0xFF));
|
||||||
|
SDL_UpdateWindowSurface(window);
|
||||||
|
// hack to make it stay open
|
||||||
|
SDL_Event e;
|
||||||
|
bool quit = false;
|
||||||
|
while (!quit) {
|
||||||
|
while (SDL_PollEvent(&e) != 0) {
|
||||||
|
if (e.type == SDL_QUIT) {
|
||||||
|
quit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
return usage();
|
return usage();
|
||||||
}
|
}
|
||||||
std::deque<std::string> args;
|
std::deque<std::string> args;
|
||||||
for (int i = 1; i < argc; i++) args.push_back(std::string(argv[i]));
|
for (int i = 1; i < argc; i++)
|
||||||
std::string a1 = std::string(args[0]);
|
args.push_back(std::string(argv[i]));
|
||||||
// XXX: Is this really needed?
|
std::string a1 = std::string(args[0]);
|
||||||
std::transform(a1.begin(), a1.end(), a1.begin(), [](unsigned char c){return std::tolower(c);});
|
// XXX: Is this really needed?
|
||||||
args.pop_front();
|
std::transform(a1.begin(), a1.end(), a1.begin(),
|
||||||
if (a1 == "init") {
|
[](unsigned char c) { return std::tolower(c); });
|
||||||
return create_fs(args);
|
args.pop_front();
|
||||||
}
|
if (a1 == "init") {
|
||||||
if (a1 == "build") return build_project(args);
|
return create_fs(args);
|
||||||
if (a1 == "run") return run_project(args);
|
}
|
||||||
if (a1 == "clean") return clean_project(args);
|
if (a1 == "build")
|
||||||
if (a1 == "devel") return devel(args);
|
return build_project(args);
|
||||||
std::string kw;
|
if (a1 == "run")
|
||||||
if (a1.substr(0, 2) == "--") {
|
return run_project(args);
|
||||||
kw = a1.substr(2);
|
if (a1 == "clean")
|
||||||
if (kw == "version") return show_version();
|
return clean_project(args);
|
||||||
if (kw == "help") return show_help();
|
if (a1 == "devel")
|
||||||
}
|
return devel(args);
|
||||||
if (a1.substr(0, 1) == "-") {
|
std::string kw;
|
||||||
// TODO: Although not yet needed, add support for multiparams, like `ceev -hv'
|
if (a1.substr(0, 2) == "--") {
|
||||||
// True, that doesn't make sense, that's why it's not yet needed.
|
kw = a1.substr(2);
|
||||||
kw = a1.substr(1);
|
if (kw == "version")
|
||||||
if (kw == "v") return show_version();
|
return show_version();
|
||||||
if (kw == "h") return show_help();
|
if (kw == "help")
|
||||||
}
|
return show_help();
|
||||||
std::cerr << bg_red(bold("ERROR")) << ": Unknown command `" << bright_magenta(a1) << "'\n" << std::endl;
|
}
|
||||||
return usage();
|
if (a1.substr(0, 1) == "-") {
|
||||||
|
// TODO: Although not yet needed, add support for multiparams, like `ceev
|
||||||
|
// -hv' True, that doesn't make sense, that's why it's not yet needed.
|
||||||
|
kw = a1.substr(1);
|
||||||
|
if (kw == "v")
|
||||||
|
return show_version();
|
||||||
|
if (kw == "h")
|
||||||
|
return show_help();
|
||||||
|
}
|
||||||
|
std::cerr << bg_red(bold("ERROR")) << ": Unknown command `"
|
||||||
|
<< bright_magenta(a1) << "'\n"
|
||||||
|
<< std::endl;
|
||||||
|
return usage();
|
||||||
}
|
}
|
||||||
|
|
13
src/ceev.h
13
src/ceev.h
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -9,6 +10,8 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "colors.h"
|
||||||
|
|
||||||
#ifndef __ceev_version
|
#ifndef __ceev_version
|
||||||
#define __ceev_version "0.1.1-devel"
|
#define __ceev_version "0.1.1-devel"
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,10 +39,10 @@
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
struct config_data {
|
struct config_data {
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
std::string version = "";
|
std::string version = "";
|
||||||
std::string author = "";
|
std::string author = "";
|
||||||
std::string email = "";
|
std::string email = "";
|
||||||
};
|
};
|
||||||
int usage();
|
int usage();
|
||||||
int show_help();
|
int show_help();
|
||||||
|
@ -52,4 +55,6 @@ int clean_project(std::deque<std::string> args);
|
||||||
int devel(std::deque<std::string> args);
|
int devel(std::deque<std::string> args);
|
||||||
int devel_help();
|
int devel_help();
|
||||||
int devel_commitinfo();
|
int devel_commitinfo();
|
||||||
|
int devel_roadmap();
|
||||||
|
int devel_sdl2(std::deque<std::string> args);
|
||||||
int main(int argc, char **argv);
|
int main(int argc, char **argv);
|
||||||
|
|
Loading…
Reference in New Issue