Initialize Command::_name

(cherry picked from commit d0a769cb06)
This commit is contained in:
Eelco Dolstra
2019-12-05 20:21:22 +01:00
parent ac67685606
commit 5e449b43ed
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -224,6 +224,7 @@ MultiCommand::MultiCommand(const Commands & commands)
if (i == commands.end())
throw UsageError("'%s' is not a recognised command", ss[0]);
command = i->second();
command->_name = ss[0];
}});
}
@@ -246,6 +247,7 @@ void MultiCommand::printHelp(const string & programName, std::ostream & out)
Table2 table;
for (auto & i : commands) {
auto command = i.second();
command->_name = i.first;
auto descr = command->description();
if (!descr.empty())
table.push_back(std::make_pair(command->name(), descr));
+2
View File
@@ -195,6 +195,8 @@ struct Command : virtual Args
private:
std::string _name;
friend class MultiCommand;
public:
virtual ~Command() { }