mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +00:00
some WIP commit
This commit is contained in:
parent
0836457c17
commit
bdd1055073
2 changed files with 65 additions and 11 deletions
|
|
@ -22,8 +22,10 @@ namespace cmd {
|
|||
std::string enumname;
|
||||
};
|
||||
|
||||
struct CommandInput {
|
||||
std::string name; // command name
|
||||
class Command;
|
||||
|
||||
struct Prompt {
|
||||
Command* command;
|
||||
dynamic::List_sptr args; // positional arguments list
|
||||
dynamic::Map_sptr kwargs; // keyword arguments table
|
||||
};
|
||||
|
|
@ -50,9 +52,15 @@ namespace cmd {
|
|||
args(std::move(args)),
|
||||
kwargs(std::move(kwargs)),
|
||||
executor(executor) {}
|
||||
|
||||
Argument* getArgument(size_t index) {
|
||||
if (index >= args.size())
|
||||
return nullptr;
|
||||
return &args[index];
|
||||
}
|
||||
|
||||
dynamic::Value execute(const CommandInput& input) {
|
||||
return executor(input.args, input.kwargs);
|
||||
dynamic::Value execute(const Prompt& prompt) {
|
||||
return executor(prompt.args, prompt.kwargs);
|
||||
}
|
||||
|
||||
const std::string& getName() const {
|
||||
|
|
@ -75,7 +83,11 @@ namespace cmd {
|
|||
CommandsInterpreter(std::unique_ptr<CommandsRepository> repository)
|
||||
: repository(std::move(repository)){}
|
||||
|
||||
CommandInput parse(std::string_view text);
|
||||
Prompt parse(std::string_view text);
|
||||
|
||||
CommandsRepository* getRepository() const {
|
||||
return repository.get();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue