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.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 nihil.cli/command_node.cc (limited to 'nihil.cli/command_node.cc') diff --git a/nihil.cli/command_node.cc b/nihil.cli/command_node.cc new file mode 100644 index 0000000..98aeac1 --- /dev/null +++ b/nihil.cli/command_node.cc @@ -0,0 +1,42 @@ +/* + * This source code is released into the public domain. + */ + +module; + +#include +#include +#include +#include + +module nihil.cli; + +import nihil.core; +import nihil.error; + +namespace nihil { + +command_node::command_node(std::string_view path) noexcept + : m_path(path) +{ +} + +command_node::~command_node() +{ +} + +auto command_node::path(this command_node const &self) noexcept + -> std::string_view +{ + return self.m_path; +} + +auto command_node::invoke(int, char **) const + -> std::expected +{ + // If invoke() wasn't overridden, then this is an empty node, + // so the command was incomplete. + return std::unexpected(error(errc::incomplete_command)); +} + +} // namespace nihil -- cgit v1.2.3