From 8283ff76bc1c9131401ea8df216271a3d9238790 Mon Sep 17 00:00:00 2001 From: Ruben Dahl Date: Tue, 20 Dec 2022 22:16:21 +0100 Subject: [PATCH] Added `--help' and tidied up a bit. By tidying up I mean I removed some of the comments made by Copilot that I didn't 100% agree with. I also got ready for the main stretch before the main stretch, by readying some important functions. Functionality to come. --- DOC/README.md | 3 +++ FILE_FORMAT.md | 3 --- README.md | 31 +++++++++++++++++++---- src/ceev.cc | 67 +++++++++++++++++++++++++++++++++++++++++++++----- src/ceev.h | 6 ++++- 5 files changed, 95 insertions(+), 15 deletions(-) create mode 100644 DOC/README.md delete mode 100644 FILE_FORMAT.md diff --git a/DOC/README.md b/DOC/README.md new file mode 100644 index 0000000..c293dc0 --- /dev/null +++ b/DOC/README.md @@ -0,0 +1,3 @@ +# CeeV Language Documentation + +Coming soon... \ No newline at end of file diff --git a/FILE_FORMAT.md b/FILE_FORMAT.md deleted file mode 100644 index 29d5bcf..0000000 --- a/FILE_FORMAT.md +++ /dev/null @@ -1,3 +0,0 @@ -# The CeeV Language documentation - -Coming soon. \ No newline at end of file diff --git a/README.md b/README.md index 8f0978a..30f8e89 100644 --- a/README.md +++ b/README.md @@ -15,17 +15,38 @@ cmake .. make ``` -### Running +### Initializing a project -To run CeeV, run the following command: +Make a new folder, then run the following command: ```bash -./CeeV + ./ceev init ``` -## File Format +### Building the project -CeeV uses a custom file format to store visual novel data. The file format is described in [FILE_FORMAT.md](FILE_FORMAT.md). +Run the following command: + +```bash + ./ceev build +``` + +### Running the project + +Run the following command: + +```bash + ./ceev run +``` + +### More help + +Run the following command: + +```bash + ./ceev --help +``` +if you need more help. ## License diff --git a/src/ceev.cc b/src/ceev.cc index b5dc12f..44e12f3 100644 --- a/src/ceev.cc +++ b/src/ceev.cc @@ -1,26 +1,81 @@ #include "ceev.h" int usage() { - std::cout << "Usage:\n"; + std::cout << "Usage:"; std::cout << "\n\t"; - std::cout << program_invocation_short_name << " [verb] \n"; + std::cout << program_invocation_short_name << " [command] \n"; std::cout << "\n"; - std::cout << "Run '" << program_invocation_short_name << " --help' for more information.\n" << std::endl; + std::cout << "Run `" << program_invocation_short_name << " --help' for more information.\n" << std::endl; return 1; } int show_help() { + // TODO: Maybe put the colorings into functions? + std::cout << program_invocation_short_name << " [\x1b[36mcommand\x1b[0m] <\x1b[92moptions\x1b[0m>\n"; + std::cout << "\n"; + std::cout << "Usage:"; + // ceev init + std::cout << "\n*\t"; + std::cout << program_invocation_short_name << " \x1b[36minit \x1b[0m<\x1b[92m--force\x1b[0m>\n"; + std::cout << "\t\t"; + std::cout << "Creates the CeeV file system. Can only be used "; + std::cout << "if the current folder is empty,"; + std::cout << "\n\t\tor when run with `\x1b[92m--force\x1b[0m'"; + // ceev build + std::cout << "\n*\t"; + std::cout << program_invocation_short_name << " \x1b[36mbuild\x1b[0m\n"; + std::cout << "\t\t"; + std::cout << "Not yet implemented"; + // ceev run + std::cout << "\n*\t"; + std::cout << program_invocation_short_name << " \x1b[36mrun\x1b[0m\n"; + std::cout << "\t\t"; + std::cout << "Not yet implemented"; + // ceev --help + std::cout << "\n*\t"; + std::cout << program_invocation_short_name << " \x1b[36m--help\x1b[0m\n"; + std::cout << "\t\t"; + std::cout << "This help page.\n"; + std::cout << std::endl; return 0; } -int create_fs() { +int create_fs(std::deque args) { std::string cwd = fs::current_path(); + if (!fs::is_empty(cwd) && args[0] != "--force") { + std::cerr << "ERROR: Folder not empty.\n" << + "Run the command with `--force' to run anyways" << std::endl; + return 1; + } + std::cout << "running create_fs()" << std::endl; + return 0; +} +int build_project(std::deque args) { + std::cout << "Building project..." << std::endl; + return 0; +} +int run_project(std::deque args) { + std::cout << "Running project..." << std::endl; + return 0; } int main(int argc, char **argv) { if (argc <= 1) { return usage(); } - if (std::strcmp(argv[1], "init")) return create_fs(); - if (std::strcmp(argv[1], "--help")) return show_help(); + std::deque args; + for (int i = 1; i < argc; i++) args.push_back(std::string(argv[i])); + std::string a1 = std::string(args[0]); + std::transform(a1.begin(), a1.end(), a1.begin(), [](unsigned char c){return std::tolower(c);}); + args.pop_front(); + if (a1 == "init") { + return create_fs(args); + } + if (a1 == "build") return build_project(args); + if (a1 == "run") return run_project(args); + std::string kw; + if (a1.substr(0, 2) == "--") { + kw = a1.substr(2); + if (kw == "help") return show_help(); + } return 0; } \ No newline at end of file diff --git a/src/ceev.h b/src/ceev.h index e2b8ea6..aaecd36 100644 --- a/src/ceev.h +++ b/src/ceev.h @@ -1,12 +1,16 @@ #pragma once +#include #include #include #include +#include namespace fs = std::filesystem; int usage(); int show_help(); -int create_fs(); +int create_fs(std::deque args); +int build_project(std::deque args); +int run_project(std::deque args); int main(int argc, char **argv); \ No newline at end of file