mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Initialize Command::_name
This commit is contained in:
parent
e75ffbf04a
commit
d0a769cb06
2 changed files with 5 additions and 0 deletions
|
@ -224,6 +224,7 @@ MultiCommand::MultiCommand(const Commands & commands)
|
||||||
if (i == commands.end())
|
if (i == commands.end())
|
||||||
throw UsageError("'%s' is not a recognised command", ss[0]);
|
throw UsageError("'%s' is not a recognised command", ss[0]);
|
||||||
command = i->second();
|
command = i->second();
|
||||||
|
command->_name = ss[0];
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +247,7 @@ void MultiCommand::printHelp(const string & programName, std::ostream & out)
|
||||||
Table2 table;
|
Table2 table;
|
||||||
for (auto & i : commands) {
|
for (auto & i : commands) {
|
||||||
auto command = i.second();
|
auto command = i.second();
|
||||||
|
command->_name = i.first;
|
||||||
auto descr = command->description();
|
auto descr = command->description();
|
||||||
if (!descr.empty())
|
if (!descr.empty())
|
||||||
table.push_back(std::make_pair(command->name(), descr));
|
table.push_back(std::make_pair(command->name(), descr));
|
||||||
|
|
|
@ -195,7 +195,10 @@ struct Command : virtual Args
|
||||||
private:
|
private:
|
||||||
std::string _name;
|
std::string _name;
|
||||||
|
|
||||||
|
friend class MultiCommand;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
std::string name() { return _name; }
|
std::string name() { return _name; }
|
||||||
|
|
||||||
virtual void prepare() { };
|
virtual void prepare() { };
|
||||||
|
|
Loading…
Reference in a new issue