diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-11-22 15:59:52 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-02-11 11:55:22 +0100 |
commit | 15a16e5c05d547ec07170df2392263e5e891447b (patch) | |
tree | 13f04586c45bf9df2f80c592ebf509c744dab130 /src/nix/command.cc | |
parent | aa0e2a2e70a3519a9dcb9b1da000a13c01aa6cc1 (diff) |
MultiCommand: Simplify construction
Diffstat (limited to 'src/nix/command.cc')
-rw-r--r-- | src/nix/command.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nix/command.cc b/src/nix/command.cc index 3d7d582d6..e760c17d5 100644 --- a/src/nix/command.cc +++ b/src/nix/command.cc @@ -4,7 +4,7 @@ namespace nix { -Commands * RegisterCommand::commands = 0; +std::vector<ref<Command>> * RegisterCommand::commands = 0; void Command::printHelp(const string & programName, std::ostream & out) { @@ -21,9 +21,11 @@ void Command::printHelp(const string & programName, std::ostream & out) } } -MultiCommand::MultiCommand(const Commands & _commands) - : commands(_commands) +MultiCommand::MultiCommand(const std::vector<ref<Command>> & _commands) { + for (auto & command : _commands) + commands.emplace(command->name(), command); + expectedArgs.push_back(ExpectedArg{"command", 1, true, [=](std::vector<std::string> ss) { assert(!command); auto i = commands.find(ss[0]); |