aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/legacy.hh
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2021-01-26 06:22:24 -0500
committerShea Levy <shea@shealevy.com>2021-01-26 06:22:24 -0500
commit6af6e41df06f0a8a3b919b4052b41d09f0a97678 (patch)
tree2b2a3a8c199151b3ffc21599a9a0f06adeea1ff3 /src/libcmd/legacy.hh
parent36c4d6f59247826dde32ad2e6b5a9471a9a1c911 (diff)
Move command plugin interface to libnixcmd
Diffstat (limited to 'src/libcmd/legacy.hh')
-rw-r--r--src/libcmd/legacy.hh23
1 files changed, 23 insertions, 0 deletions
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 <functional>
+#include <map>
+#include <string>
+
+namespace nix {
+
+typedef std::function<void(int, char * *)> MainFunction;
+
+struct RegisterLegacyCommand
+{
+ typedef std::map<std::string, MainFunction> Commands;
+ static Commands * commands;
+
+ RegisterLegacyCommand(const std::string & name, MainFunction fun)
+ {
+ if (!commands) commands = new Commands;
+ (*commands)[name] = fun;
+ }
+};
+
+}