Commit 9a454c8e4e2b1356f356627bad6e3b932efd23c3

Authored by Akos Kiss
Committed by GitHub
1 parent 794c9752

Improve help of short-only options (remove dangling comma) (#235)

include/cxxopts.hpp
... ... @@ -1468,7 +1468,11 @@ namespace cxxopts
1468 1468  
1469 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 1477 else
1474 1478 {
... ...
src/example.cpp
... ... @@ -49,6 +49,7 @@ parse(int argc, char* argv[])
49 49 ("i,input", "Input", cxxopts::value<std::string>())
50 50 ("o,output", "Output file", cxxopts::value<std::string>()
51 51 ->default_value("a.out")->implicit_value("b.def"), "BIN")
  52 + ("x", "A short-only option", cxxopts::value<std::string>())
52 53 ("positional",
53 54 "Positional arguments: these are the arguments that are entered "
54 55 "without an option", cxxopts::value<std::vector<std::string>>())
... ...