forked from cafeberry/cafeberry
feat: add smartcmd dedicated server
major bug: when connecting to the server a second time, it gets softlocked and keeps repeating ticking connection A\n in debug logs until it times out.
This commit is contained in:
@@ -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);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user