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.
master
Ruben Dahl 2022-12-20 22:16:21 +01:00
parent d1c6c52d22
commit 8283ff76bc
No known key found for this signature in database
GPG Key ID: C7838D0300EDEF1B
5 changed files with 95 additions and 15 deletions

3
DOC/README.md 100644
View File

@ -0,0 +1,3 @@
# CeeV Language Documentation
Coming soon...

View File

@ -1,3 +0,0 @@
# The CeeV Language documentation
Coming soon.

View File

@ -15,17 +15,38 @@ cmake ..
make make
``` ```
### Running ### Initializing a project
To run CeeV, run the following command: Make a new folder, then run the following command:
```bash ```bash
./CeeV <path to .cv file> ./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 ## License

View File

@ -1,26 +1,81 @@
#include "ceev.h" #include "ceev.h"
int usage() { int usage() {
std::cout << "Usage:\n"; std::cout << "Usage:";
std::cout << "\n\t"; std::cout << "\n\t";
std::cout << program_invocation_short_name << " [verb] <options>\n"; std::cout << program_invocation_short_name << " [command] <options>\n";
std::cout << "\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; return 1;
} }
int show_help() { 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; return 0;
} }
int create_fs() { int create_fs(std::deque<std::string> args) {
std::string cwd = fs::current_path(); 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<std::string> args) {
std::cout << "Building project..." << std::endl;
return 0;
}
int run_project(std::deque<std::string> args) {
std::cout << "Running project..." << std::endl;
return 0;
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
if (argc <= 1) { if (argc <= 1) {
return usage(); return usage();
} }
if (std::strcmp(argv[1], "init")) return create_fs(); std::deque<std::string> args;
if (std::strcmp(argv[1], "--help")) return show_help(); 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; return 0;
} }

View File

@ -1,12 +1,16 @@
#pragma once #pragma once
#include <algorithm>
#include <cstring> #include <cstring>
#include <filesystem> #include <filesystem>
#include <iostream> #include <iostream>
#include <deque>
namespace fs = std::filesystem; namespace fs = std::filesystem;
int usage(); int usage();
int show_help(); int show_help();
int create_fs(); int create_fs(std::deque<std::string> args);
int build_project(std::deque<std::string> args);
int run_project(std::deque<std::string> args);
int main(int argc, char **argv); int main(int argc, char **argv);