ReXGlue SDK
Loading...
Searching...
No Matches
console_command.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#include <memory>
15#include <string>
16#include <string_view>
17
18#include <rex/platform.h>
19#include <rex/result.h>
20#include <rex/setting.h>
21#include <rex/utility.h>
22
23namespace rex {
24
26class REX_API ConsoleCommand : public NonCopyable {
27 public:
31 ConsoleCommand(SettingOwner* owner, std::string_view name, std::string_view help,
32 MoveOnlyFunction<Result<void>(std::string_view args)> run);
33
35
39 const std::string& GetName() const;
40
41 const std::string& GetHelp() const;
42
43 [[nodiscard]] Result<void> Run(std::string_view args);
44
45 private:
46 struct State;
47 std::unique_ptr<State> state_;
48};
49
50} // namespace rex
51
63#define REX_COMMAND(name, help, fn) \
64 ::rex::ConsoleCommand name { \
65 this, #name, help, fn \
66 }
const std::string & GetName() const
ConsoleCommand(SettingOwner *owner, std::string_view name, std::string_view help, MoveOnlyFunction< Result< void >(std::string_view args)> run)
Definition setting.h:249
Definition app.h:36
typename detail::MoveOnlyFunctionFor< Signature >::type MoveOnlyFunction
Definition utility.h:254
std::expected< T, Error > Result
Definition result.h:98
Platform flags, packing macros and export markers.
#define REX_API
Definition platform.h:177
Typed settings and the owners that declare them.
Move only function, const propagating pointer and scope guard.