From 378dd663a402fe196f2b56c6413eb3f623aecbbf Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Tue, 1 Jul 2025 19:18:42 +0100 Subject: cli: refactoring --- nihil.cli/registry.cc | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'nihil.cli/registry.cc') diff --git a/nihil.cli/registry.cc b/nihil.cli/registry.cc index 0f0041b..a972a65 100644 --- a/nihil.cli/registry.cc +++ b/nihil.cli/registry.cc @@ -5,13 +5,11 @@ import nihil.std; namespace nihil { -/* - * Get the registry storage. Because this is called from global ctors, - * it handles exceptions itself. - */ -auto get_registry() noexcept -> std::vector> & +// Get the registry storage. Because this is called from global ctors, +// it handles exceptions itself. +auto get_registry() noexcept -> std::vector> & try { - static auto commands = std::vector>(); + static auto commands = std::vector>(); return commands; } catch (std::exception const &exc) { std::println(std::cerr, "{}", exc.what()); @@ -21,12 +19,10 @@ try { std::exit(1); // NOLINT } -/* - * Register a new command. - */ +// Register a new command. auto register_command(command *cmd) noexcept -> void try { - auto null_deleter = [] (command_node const *) -> void {}; + auto null_deleter = [] (command const *) -> void {}; auto &commands = get_registry(); commands.emplace_back(cmd, null_deleter); @@ -38,10 +34,8 @@ try { std::exit(1); // NOLINT } -/* - * Get the list of registered commands. - */ -auto get_registered_commands() -> std::span> +// Get the list of registered commands. +auto get_registered_commands() -> std::span> { return {get_registry()}; } -- cgit v1.2.3