Add string handling to console arguments
This commit is contained in:
parent
2524213f01
commit
5ba4285776
3 changed files with 11 additions and 2 deletions
|
@ -14,6 +14,8 @@ namespace prism::console {
|
|||
};
|
||||
|
||||
struct console_argument {
|
||||
explicit console_argument(std::string_view string) : data(string.data()) {}
|
||||
|
||||
explicit console_argument(bool data) : data(data) {}
|
||||
|
||||
explicit console_argument(int data) : data(data) {}
|
||||
|
|
|
@ -88,6 +88,8 @@ void prism::console::parse_and_invoke_command(const std::string_view command) {
|
|||
return console_argument(false);
|
||||
} else if(is_numeric(arg)) {
|
||||
return console_argument(std::stoi(arg.data()));
|
||||
} else {
|
||||
return console_argument(arg);
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
|
|
|
@ -28,8 +28,13 @@ using prism::engine;
|
|||
engine::engine(const int argc, char* argv[]) {
|
||||
log("Prism Engine loading...");
|
||||
|
||||
console::register_command("test_cmd", console::argument_format(0), [](const console::arguments&) {
|
||||
log("Test cmd!");
|
||||
console::register_command("echo", console::argument_format(1), [](const console::arguments& args) {
|
||||
log(std::get<std::string>(args[0].data));
|
||||
});
|
||||
|
||||
console::register_command("platform_info", console::argument_format(0), [this](const console::arguments&) {
|
||||
log("Platform: {}", platform::get_name());
|
||||
log("GFX: {}", gfx->get_name());
|
||||
});
|
||||
|
||||
console::register_variable("rs_dynamic_resolution", render_options.dynamic_resolution);
|
||||
|
|
Reference in a new issue