Browse Source

Moved help hack into cxxopts.

* Added some dumb, hacky code to cxxopts to hide groups with a certain name.
    * main.cpp now uses options.help() instead of specifying group names.
master
Ian Burgmyer 4 years ago
parent
commit
1bde3c0e64
  1. 6
      plip-sdl/cxxopts.hpp
  2. 7
      plip-sdl/main.cpp

6
plip-sdl/cxxopts.hpp

@ -54,6 +54,7 @@ THE SOFTWARE.
namespace cxxopts
{
const char *hidden_group = "--HIDDEN--";
static constexpr struct {
uint8_t major, minor, patch;
} version = {
@ -2042,7 +2043,10 @@ Options::generate_all_groups_help(String& result) const
for (auto& group : m_help)
{
all_groups.push_back(group.first);
// Very hacky, but more convenient than the alternative.
auto group_name = group.first;
if(group_name == hidden_group) continue;
all_groups.push_back(group_name);
}
generate_group_help(result, all_groups);

7
plip-sdl/main.cpp

@ -16,7 +16,7 @@ cxxopts::ParseResult parseCmdLine(int argc, char **argv) {
options.positional_help("CORE FILENAME")
.show_positional_help();
options.add_options("Hidden")
options.add_options(cxxopts::hidden_group)
("c,core", "the core that should be used", cxxopts::value<std::string>())
("f,filename", "the path to the ROM", cxxopts::value<std::string>())
("positional", "", cxxopts::value<std::vector<std::string>>())
@ -37,10 +37,7 @@ cxxopts::ParseResult parseCmdLine(int argc, char **argv) {
if(result.count("help")) {
// Icky hack. As far as I can tell there's no other way of hiding
// unwanted/positional arguments using cxxopts.
std::cout << options.help({
"",
"Video"
}) << std::endl;
std::cout << options.help() << std::endl;
exit(0);
}

Loading…
Cancel
Save