aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/legacy.hh
diff options
context:
space:
mode:
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;
+ }
+};
+
+}