aboutsummaryrefslogtreecommitdiff
path: root/src/nix/command.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/command.hh')
-rw-r--r--src/nix/command.hh13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/nix/command.hh b/src/nix/command.hh
index d60c8aeb6..6882db195 100644
--- a/src/nix/command.hh
+++ b/src/nix/command.hh
@@ -176,20 +176,29 @@ struct StorePathCommand : public InstallablesCommand
/* A helper class for registering commands globally. */
struct RegisterCommand
{
+ typedef std::map<std::vector<std::string>, std::function<ref<Command>()>> Commands;
static Commands * commands;
- RegisterCommand(const std::string & name,
+ RegisterCommand(std::vector<std::string> && name,
std::function<ref<Command>()> command)
{
if (!commands) commands = new Commands;
commands->emplace(name, command);
}
+
+ static nix::Commands getCommandsFor(const std::vector<std::string> & prefix);
};
template<class T>
static RegisterCommand registerCommand(const std::string & name)
{
- return RegisterCommand(name, [](){ return make_ref<T>(); });
+ return RegisterCommand({name}, [](){ return make_ref<T>(); });
+}
+
+template<class T>
+static RegisterCommand registerCommand2(std::vector<std::string> && name)
+{
+ return RegisterCommand(std::move(name), [](){ return make_ref<T>(); });
}
Buildables build(ref<Store> store, Realise mode,