diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-29 00:42:31 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-29 00:42:31 +0100 |
| commit | d24315268c11d435bb9accbce87b7f46dda6ed3e (patch) | |
| tree | 66589cb6a15fa74d4b09683105c583e4a5c222b4 /nihil.cli/command_node.ccm | |
| parent | 7741a9698d29f79aca3e47495dcdf87c7a712f42 (diff) | |
| download | nihil-d24315268c11d435bb9accbce87b7f46dda6ed3e.tar.gz nihil-d24315268c11d435bb9accbce87b7f46dda6ed3e.tar.bz2 | |
cli: improve command dispatch a bit
Diffstat (limited to 'nihil.cli/command_node.ccm')
| -rw-r--r-- | nihil.cli/command_node.ccm | 35 |
1 files changed, 35 insertions, 0 deletions
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 <expected> +#include <string> + +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<int, error>; + +private: + std::string m_path; +}; + +} // namespace nihil |
