|
| | Commands () |
| | Creates the commands, with help only.
|
| |
| void | add (std::string_view name, std::vector< CommandArg > arguments, std::string_view description, CommandHandler handler) |
| | Adds a command.
|
| |
| void | add_variables (ConsoleVariables &variables) noexcept |
| | Makes the variables of a registry commands too.
|
| |
| bool | contains (std::string_view name) const |
| | Tells whether a line can start with a name.
|
| |
| CommandResult | run (std::string_view line) |
| | Runs a line.
|
| |
| std::string | usage (std::string_view name) const |
| | How to call a command.
|
| |
| std::vector< std::string > | names () const |
| | Names of the commands and the variables, in alphabetical order.
|
| |
The commands a console runs: each has a name, its arguments and a help.
A line is a command's name and its arguments, separated by blanks; double quotes keep blanks in an argument (say "hello world"; inside them, a backslash keeps a quote or a backslash). The arguments are checked against what the command takes, in their types, before it runs. Console variables are commands too, once given with add_variables(): r_vsync shows the variable, its default and its help, r_vsync off changes it. help lists the commands and the variables, help <name> shows the usage and the help of one. Not thread-safe: use it from the game thread.
.optional = true}},
"Spawns entities of a type", [&](const core::CommandCall& call) {
const auto count = call.has("count") ? call.integer("count") : 1;
...
return std::format("{} {} spawned", count, call.text("type"));
});
commands.
run(
"spawn crate 3");
The commands a console runs: each has a name, its arguments and a help.
Definition commands.hpp:140
CommandResult run(std::string_view line)
Runs a line.
void add(std::string_view name, std::vector< CommandArg > arguments, std::string_view description, CommandHandler handler)
Adds a command.