diff options
-rw-r--r-- | src/libutil/args.cc | 7 | ||||
-rw-r--r-- | src/libutil/args.hh | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc index 6e4b82a279ce..115484f9e6c7 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -71,10 +71,11 @@ void Args::printHelp(const string & programName, std::ostream & out) void Args::printFlags(std::ostream & out) { Table2 table; - for (auto & flags : longFlags) + for (auto & flag : longFlags) table.push_back(std::make_pair( - "--" + flags.first + renderLabels(flags.second.labels), - flags.second.description)); + (flag.second.shortName ? std::string("-") + flag.second.shortName + ", " : " ") + + "--" + flag.first + renderLabels(flag.second.labels), + flag.second.description)); printTable(out, table); } diff --git a/src/libutil/args.hh b/src/libutil/args.hh index 4469a046d28a..6aa08aacac9e 100644 --- a/src/libutil/args.hh +++ b/src/libutil/args.hh @@ -29,6 +29,7 @@ protected: /* Flags. */ struct Flag { + char shortName; std::string description; Strings labels; size_t arity; @@ -63,7 +64,7 @@ public: const Strings & labels, const std::string & description, size_t arity, std::function<void(Strings)> handler) { - auto flag = Flag{description, labels, arity, handler}; + auto flag = Flag{shortName, description, labels, arity, handler}; if (shortName) shortFlags[shortName] = flag; longFlags[longName] = flag; } |