diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-06-19 23:37:40 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-12-05 20:21:22 +0100 |
commit | 5e449b43ed31a518e13b21363ae3ba1994ce1cd7 (patch) | |
tree | 0d07b82727485c3225065fb5497bbbb47a504765 /src | |
parent | ac676856061677559a21670940ac2fac98add9a0 (diff) |
Initialize Command::_name
(cherry picked from commit d0a769cb061a13ad880c76e5ea69a76150439853)
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/args.cc | 2 | ||||
-rw-r--r-- | src/libutil/args.hh | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc index 217495c26..ba15ea571 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -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)); diff --git a/src/libutil/args.hh b/src/libutil/args.hh index 54336b17b..967efbe1c 100644 --- a/src/libutil/args.hh +++ b/src/libutil/args.hh @@ -195,6 +195,8 @@ struct Command : virtual Args private: std::string _name; + friend class MultiCommand; + public: virtual ~Command() { } |