mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 22:12:43 +01:00
MultiCommand: Simplify construction
This commit is contained in:
parent
aa0e2a2e70
commit
15a16e5c05
3 changed files with 15 additions and 8 deletions
|
|
@ -173,7 +173,7 @@ public:
|
|||
|
||||
std::shared_ptr<Command> command;
|
||||
|
||||
MultiCommand(const Commands & commands);
|
||||
MultiCommand(const std::vector<ref<Command>> & commands);
|
||||
|
||||
void printHelp(const string & programName, std::ostream & out) override;
|
||||
|
||||
|
|
@ -185,12 +185,12 @@ public:
|
|||
/* A helper class for registering commands globally. */
|
||||
struct RegisterCommand
|
||||
{
|
||||
static Commands * commands;
|
||||
static std::vector<ref<Command>> * commands;
|
||||
|
||||
RegisterCommand(ref<Command> command)
|
||||
{
|
||||
if (!commands) commands = new Commands;
|
||||
commands->emplace(command->name(), command);
|
||||
if (!commands) commands = new std::vector<ref<Command>>;
|
||||
commands->push_back(command);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue