10#include <unordered_map>
27 std::unordered_map<std::string, std::shared_ptr<Node>> children;
33 std::function<void(
const std::vector<std::string> &)>
function =
nullptr;
51 std::shared_ptr<Node> &ret = children[key];
53 ret = std::make_shared<Node>();
74 bool newLineAutoComplete =
true;
84 std::unordered_map<std::string, std::shared_ptr<Node>> nodes;
86 std::deque<std::string> hist;
128 void Run(std::string filename);
131 void SetRawMode_(
bool enable);
133 std::optional<char> ReadChar_();
135 bool Input_available_(
int fd,
int timeout_ms);
137 void HandleEscapeChar_();
139 void AutoComplete_();
143 void ExecuteCommand_();
145 int HandleInput_(
char ch);
147 bool VerifyHelper_(
const std::shared_ptr<Node> &node);
151 void SetupDefaultCommands_();
Console::Node & operator[](const std::string &key)
Used to add a new command.
Definition cli.hpp:50
std::function< void(const std::vector< std::string > &)> function
A function to call when executing a command.
Definition cli.hpp:33
Console represents the customisable console.
Definition cli.hpp:21
Node & operator[](const std::string &key)
Used to add a new command.
Definition cli.cpp:8
struct cli::Console::@0 settings
Console settings.
bool stop
Manages if the main loop should stop.
Definition cli.hpp:63
void Run()
Starts the custom console.
Definition cli.cpp:269