diff options
Diffstat (limited to 'Minecraft.Server/Console/ServerCliParser.h')
| -rw-r--r-- | Minecraft.Server/Console/ServerCliParser.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Minecraft.Server/Console/ServerCliParser.h b/Minecraft.Server/Console/ServerCliParser.h new file mode 100644 index 00000000..a84d179b --- /dev/null +++ b/Minecraft.Server/Console/ServerCliParser.h @@ -0,0 +1,63 @@ +#pragma once + +#include <string> +#include <vector> + +namespace ServerRuntime +{ + /** + * **Parsed command line** + */ + struct ServerCliParsedLine + { + std::string raw; + std::vector<std::string> tokens; + bool trailingSpace; + + ServerCliParsedLine() + : trailingSpace(false) + { + } + }; + + /** + * **Completion context for one input line** + * + * Indicates current token index, token prefix, and the fixed line prefix. + */ + struct ServerCliCompletionContext + { + ServerCliParsedLine parsed; + size_t currentTokenIndex; + std::string prefix; + std::string linePrefix; + + ServerCliCompletionContext() + : currentTokenIndex(0) + { + } + }; + + /** + * **CLI parser helpers** + * + * Converts raw input text into tokenized data used by execution and completion. + */ + class ServerCliParser + { + public: + /** + * **Tokenize one command line** + * + * Supports quoted segments and escaped characters. + */ + static ServerCliParsedLine Parse(const std::string &line); + + /** + * **Build completion metadata** + * + * Determines active token position and reusable prefix parts. + */ + static ServerCliCompletionContext BuildCompletionContext(const std::string &line); + }; +} |
