From f032a4a7b14fc8c60b1a07d44c38fdff573b3baa Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Wed, 20 Jan 2016 15:05:29 -0800 Subject: Fix command-line help when there's only long or short --- src/support/command-line.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/support/command-line.cpp b/src/support/command-line.cpp index c078ef45f..b4f8a4d62 100644 --- a/src/support/command-line.cpp +++ b/src/support/command-line.cpp @@ -32,9 +32,11 @@ Options::Options(const std::string &command, const std::string &description) } // TODO: line-wrap description. for (const auto &o : options) { + bool long_n_short = o.longName.size() != 0 && o.shortName.size() != 0; size_t pad = 1 + optionWidth - o.longName.size() - o.shortName.size(); - std::cerr << " " << o.longName << ',' << o.shortName - << std::string(pad, ' ') << o.description << '\n'; + std::cerr << " " << o.longName << (long_n_short ? ',' : ' ') + << o.shortName << std::string(pad, ' ') << o.description + << '\n'; } std::cerr << '\n'; exit(EXIT_SUCCESS); -- cgit v1.2.3