From 9a454c8e4e2b1356f356627bad6e3b932efd23c3 Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Thu, 4 Jun 2020 05:21:51 +0200 Subject: [PATCH] Improve help of short-only options (remove dangling comma) (#235) --- include/cxxopts.hpp | 6 +++++- src/example.cpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index e47cb81..97381a9 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -1468,7 +1468,11 @@ namespace cxxopts if (!s.empty()) { - result += "-" + toLocalString(s) + ","; + result += "-" + toLocalString(s); + if (!l.empty()) + { + result += ","; + } } else { diff --git a/src/example.cpp b/src/example.cpp index c94025b..9b6ea88 100644 --- a/src/example.cpp +++ b/src/example.cpp @@ -49,6 +49,7 @@ parse(int argc, char* argv[]) ("i,input", "Input", cxxopts::value()) ("o,output", "Output file", cxxopts::value() ->default_value("a.out")->implicit_value("b.def"), "BIN") + ("x", "A short-only option", cxxopts::value()) ("positional", "Positional arguments: these are the arguments that are entered " "without an option", cxxopts::value>())