VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
CommandSyntax.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <string>
5#include <string_view>
6#include <vector>
7
9{
10
11/**
12 * @file CommandSyntax.hpp
13 * @brief How a chat line is spelled: the prefix, and splitting one into tokens.
14 *
15 * Pure text, no registrations and no engine, which is what keeps the whole dispatch path
16 * unit-testable. Separate from @ref CommandRouter because none of it depends on which commands
17 * happen to be registered.
18 */
19
20/** Split @p text on spaces. A `"quoted run"` is one token and `\"` is a literal quote. Repeated
21 * spaces produce no blank arguments; an explicit `""` is an empty argument. */
22std::vector<std::string> Tokenize(std::string_view text);
23
24/** @p message without its command prefix, or nullopt when it carries none. */
25std::optional<std::string_view> StripPrefix(std::string_view message);
26
27/** What starts a chat command, and what a chat usage line shows. */
28inline constexpr std::string_view ChatPrefix = "!";
29
30} // namespace VoltMod::CommandSyntax
std::optional< std::string_view > StripPrefix(std::string_view message)
constexpr std::string_view ChatPrefix
std::vector< std::string > Tokenize(std::string_view text)
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56