From d24315268c11d435bb9accbce87b7f46dda6ed3e Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sun, 29 Jun 2025 00:42:31 +0100 Subject: cli: improve command dispatch a bit --- nihil.cli/command_node.ccm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 nihil.cli/command_node.ccm (limited to 'nihil.cli/command_node.ccm') diff --git a/nihil.cli/command_node.ccm b/nihil.cli/command_node.ccm new file mode 100644 index 0000000..546eb46 --- /dev/null +++ b/nihil.cli/command_node.ccm @@ -0,0 +1,35 @@ +/* + * This source code is released into the public domain. + */ + +module; + +/* + * command_node represents a possibly-invocable command. + */ + +#include +#include + +export module nihil.cli:command_node; + +import nihil.error; + +namespace nihil { + +export struct command_node { + command_node(std::string_view path) noexcept; + + virtual ~command_node(); + + [[nodiscard]] auto path(this command_node const &) noexcept + -> std::string_view; + + [[nodiscard]] virtual auto invoke(int argc, char **argv) const + -> std::expected; + +private: + std::string m_path; +}; + +} // namespace nihil -- cgit v1.2.3