improve cmd

This commit is contained in:
西风逍遥游 committed 2021-10-24 22:37:07 -07:00
1 parent 3445b18b1f
commit a51708bb65
9 files changed
+229 -77

No files matched your search

+30 -1
View File
@@ -3,10 +3,39 @@
#include "common/Module.h"
#include <simplesquirrel/simplesquirrel.hpp>
#include <CLI11.hpp>
#include <string>
namespace eve
using namespace std;
namespace eve::cmd
{
struct RunArgs : Handler {
string log_path;
bool no_window = false, debug = false;
void setup(CLI::App& app, std::shared_ptr<CLI::Formatter> formatter) override {
auto run = app.add_subcommand("run", "Run game under current path");
run->allow_extras()->formatter(formatter);
run->add_flag("--no-window", no_window, "Run script only, no window mode");
run->add_flag("--debug", debug, "debug mode");
run->add_option("-l,--log", log_path, "log messages into a file");
}
int parse(CLI::App& app, Cmdline& cmd) override {
auto run = app.get_subcommand("run");
if (run->parsed() || cmd.getArgc() == 1) {
string current_path = cmd.get_remaining(run);
return cmd.Run(current_path);
}
return -1; // not handle
}
};
CMD_REG(RunArgs);
// create a new project
int Cmdline::Run(std::string path) {
ssq::VM vm(2048, ssq::Libs::ALL);