Commit 9a454c8e4e2b1356f356627bad6e3b932efd23c3
Committed by
GitHub
1 parent
794c9752
Improve help of short-only options (remove dangling comma) (#235)
Showing
2 changed files
with
6 additions
and
1 deletions
include/cxxopts.hpp
| @@ -1468,7 +1468,11 @@ namespace cxxopts | @@ -1468,7 +1468,11 @@ namespace cxxopts | ||
| 1468 | 1468 | ||
| 1469 | if (!s.empty()) | 1469 | if (!s.empty()) |
| 1470 | { | 1470 | { |
| 1471 | - result += "-" + toLocalString(s) + ","; | 1471 | + result += "-" + toLocalString(s); |
| 1472 | + if (!l.empty()) | ||
| 1473 | + { | ||
| 1474 | + result += ","; | ||
| 1475 | + } | ||
| 1472 | } | 1476 | } |
| 1473 | else | 1477 | else |
| 1474 | { | 1478 | { |
src/example.cpp
| @@ -49,6 +49,7 @@ parse(int argc, char* argv[]) | @@ -49,6 +49,7 @@ parse(int argc, char* argv[]) | ||
| 49 | ("i,input", "Input", cxxopts::value<std::string>()) | 49 | ("i,input", "Input", cxxopts::value<std::string>()) |
| 50 | ("o,output", "Output file", cxxopts::value<std::string>() | 50 | ("o,output", "Output file", cxxopts::value<std::string>() |
| 51 | ->default_value("a.out")->implicit_value("b.def"), "BIN") | 51 | ->default_value("a.out")->implicit_value("b.def"), "BIN") |
| 52 | + ("x", "A short-only option", cxxopts::value<std::string>()) | ||
| 52 | ("positional", | 53 | ("positional", |
| 53 | "Positional arguments: these are the arguments that are entered " | 54 | "Positional arguments: these are the arguments that are entered " |
| 54 | "without an option", cxxopts::value<std::vector<std::string>>()) | 55 | "without an option", cxxopts::value<std::vector<std::string>>()) |