mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-02-16 10:41:01 +00:00
Use proper argument parser
This commit is contained in:
@@ -4,8 +4,10 @@
|
||||
#include "commandline.h"
|
||||
#include <atomic>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class TLuaEngine;
|
||||
@@ -34,10 +36,20 @@ private:
|
||||
void Command_Settings(const std::string& cmd, const std::vector<std::string>& args);
|
||||
|
||||
void Command_Say(const std::string& FullCommand);
|
||||
bool ExpectArgsCount(const std::vector<std::string>& args, size_t n);
|
||||
bool ExpectArgsCount(const std::vector<std::string>& args, size_t min, size_t max);
|
||||
bool EnsureArgsCount(const std::vector<std::string>& args, size_t n);
|
||||
bool EnsureArgsCount(const std::vector<std::string>& args, size_t min, size_t max);
|
||||
|
||||
static std::tuple<std::string, std::vector<std::string>> ParseCommand(const std::string& cmd);
|
||||
static std::string ConcatArgs(const std::vector<std::string>& args, char space = ' ');
|
||||
|
||||
std::unordered_map<std::string, std::function<void(const std::string&, const std::vector<std::string>&)>> mCommandMap = {
|
||||
{ "lua", [this](const auto& a, const auto& b) { Command_Lua(a, b); } },
|
||||
{ "help", [this](const auto& a, const auto& b) { Command_Help(a, b); } },
|
||||
{ "kick", [this](const auto& a, const auto& b) { Command_Kick(a, b); } },
|
||||
{ "list", [this](const auto& a, const auto& b) { Command_List(a, b); } },
|
||||
{ "status", [this](const auto& a, const auto& b) { Command_Status(a, b); } },
|
||||
{ "settings", [this](const auto& a, const auto& b) { Command_Settings(a, b); } },
|
||||
};
|
||||
|
||||
Commandline mCommandline;
|
||||
std::vector<std::string> mCachedLuaHistory;
|
||||
|
||||
Reference in New Issue
Block a user