From d2c471c2300141529983be425f7ad75d371fcdf7 Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 23 Aug 2018 11:49:16 -0400 Subject: prettify help info --- src/util.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 7ef01a9..07849fc 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -251,9 +251,13 @@ size_t Config::parse(int argc, char **argv) { } void Config::print_help(FILE *output) { + int width = 0; + for (const auto &opt: opts) + width = std::max(width, (int)opt->optname.length()); for (const auto &opt: opts) { - fprintf(output, "--%s\t\t", opt->optname.c_str()); + fprintf(output, " --%s%*c", opt->optname.c_str(), + width - (int)opt->optname.length() + 4, ' '); if (opt->short_opt != -1) fprintf(output, "-%c\t", opt->short_opt); else -- cgit v1.2.3