From 6af6e41df06f0a8a3b919b4052b41d09f0a97678 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Tue, 26 Jan 2021 06:22:24 -0500 Subject: Move command plugin interface to libnixcmd --- src/libcmd/legacy.hh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/libcmd/legacy.hh (limited to 'src/libcmd/legacy.hh') diff --git a/src/libcmd/legacy.hh b/src/libcmd/legacy.hh new file mode 100644 index 000000000..f503b0da3 --- /dev/null +++ b/src/libcmd/legacy.hh @@ -0,0 +1,23 @@ +#pragma once + +#include +#include +#include + +namespace nix { + +typedef std::function MainFunction; + +struct RegisterLegacyCommand +{ + typedef std::map Commands; + static Commands * commands; + + RegisterLegacyCommand(const std::string & name, MainFunction fun) + { + if (!commands) commands = new Commands; + (*commands)[name] = fun; + } +}; + +} -- cgit v1.2.3