104 std::function<Result<Reply>(
const Caller&, std::span<const BoundArg>)>
Invoke;
128 "A command handler takes (Caller, Args::...) and returns Result<Reply> or nothing. A generic lambda "
129 "cannot be one: its parameter list is the argument specification, so the types have to be "
134template <HasOneCallOperator F>
139template <
class R,
class... A>
147template <
class C,
class R,
class... A>
151template <
class C,
class R,
class... A>
155template <
class C,
class R,
class... A>
159template <
class C,
class R,
class... A>
163template <
class R,
class... A>
167template <
class R,
class... A>
199 _def.
Name = std::string(name);
259 template <
class F,
class... A>
262 static_assert((
CommandArg<A> && ...),
"Every command handler parameter after Caller must be an Args:: type.");
263 static_assert(
OptionalsTrail<A...>(),
"Only trailing command arguments may be Args::Opt.");
264 static_assert(
RestIsLast<A...>(),
"Args::Rest must be the last command argument.");
266 std::function<Result<Reply>(
Caller, A...)>
fn;
267 if constexpr (std::is_void_v<std::invoke_result_t<std::decay_t<F>&,
Caller, A...>>)
281 return Unpack(
fn,
caller,
bound, std::index_sequence_for<A...>{});
283 _install(std::move(_def));
287 template <
class... A, std::size_t...
I>
289 std::span<const BoundArg>
bound, std::index_sequence<I...>)
295 CommandDefinition _def;
Fluent command registration, returned by CommandManager::Add.
std::function< void(CommandDefinition)> Installer
CommandBuilder & Anywhere()
CommandBuilder & Alias(std::string_view alias)
CommandBuilder & UsageKey(std::string_view key)
CommandBuilder & Describe(std::string_view text)
CommandBuilder(Installer install, std::string_view name)
CommandBuilder & Permission(std::string_view permission)
CommandBuilder & ServerOnly()
One connected player, owned by PlayerManager for the length of the connection.
Localization system. Loads one JSON file per language; nested objects flatten into dotted keys (categ...
@ Text
Not selectable; a caption or a summary line.
consteval bool RestIsLast()
static std::string ReadFile(const std::filesystem::path &path)
std::vector< ArgDesc > DescribeArgs()
std::map< std::string, std::string > Tokens
consteval bool OptionalsTrail()
std::expected< T, Error > Result
static T From(const BoundArg &bound)
Who invoked the command, and how to answer them.
void SayRaw(std::string_view line) const
Result< Reply > Ok(std::string_view key, Tokens tokens={}) const
std::function< void(const std::string &)> Send
VoltMod::Translations & Translations
Result< Reply > Fail(std::string_view key, Tokens tokens={}) const
void Say(std::string_view key, Tokens tokens={}) const
One command as the builder assembled it.
std::string PermissionName
std::function< Result< Reply >(const Caller &, std::span< const BoundArg >)> Invoke
std::vector< std::string > Aliases
std::vector< ArgDesc > Args
The parameter list of a handler, after the leading Caller.
What a command handler answers with.