aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.cli/registry.cc
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-07-02 00:33:19 +0100
committerLexi Winter <lexi@le-fay.org>2025-07-02 00:33:19 +0100
commit8c9688fff4446a1b0f5fe9a9be0c50084726cc4d (patch)
treeca9a10be5795d976c0cbc73ad1111517bb4e22bf /nihil.cli/registry.cc
parent47999457e647352ae7e71d43c65e7b39ae5ca567 (diff)
downloadnihil-8c9688fff4446a1b0f5fe9a9be0c50084726cc4d.tar.gz
nihil-8c9688fff4446a1b0f5fe9a9be0c50084726cc4d.tar.bz2
CLI cleanups; fix the FreeBSD build
Diffstat (limited to 'nihil.cli/registry.cc')
-rw-r--r--nihil.cli/registry.cc43
1 files changed, 0 insertions, 43 deletions
diff --git a/nihil.cli/registry.cc b/nihil.cli/registry.cc
deleted file mode 100644
index a972a65..0000000
--- a/nihil.cli/registry.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// This source code is released into the public domain.
-module nihil.cli;
-
-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<std::shared_ptr<command>> &
-try {
- static auto commands = std::vector<std::shared_ptr<command>>();
- return commands;
-} catch (std::exception const &exc) {
- std::println(std::cerr, "{}", exc.what());
- std::exit(1); // NOLINT
-} catch (...) {
- std::println(std::cerr, "get_registered_commands(): unknown error\n");
- std::exit(1); // NOLINT
-}
-
-// Register a new command.
-auto register_command(command *cmd) noexcept -> void
-try {
- auto null_deleter = [] (command const *) -> void {};
-
- auto &commands = get_registry();
- commands.emplace_back(cmd, null_deleter);
-} catch (std::exception const &exc) {
- std::println(std::cerr, "{}", exc.what());
- std::exit(1); // NOLINT
-} catch (...) {
- std::println(std::cerr, "get_registered_commands(): unknown error\n");
- std::exit(1); // NOLINT
-}
-
-// Get the list of registered commands.
-auto get_registered_commands() -> std::span<std::shared_ptr<command>>
-{
- return {get_registry()};
-}
-
-} // namespace nihil