From 2c47462f8fad1c0ceb81945482be2a536871521f Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 12 Apr 2021 17:01:29 +1000 Subject: [PATCH] add hidden options to our CLI parser to ignore Qt's parameters Fixes #1511 --- app/common/commandlineparser.cpp | 8 ++++++-- app/common/commandlineparser.h | 13 ++++++++++++- app/main.cpp | 31 +++++++++++++++++++++++++------ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/app/common/commandlineparser.cpp b/app/common/commandlineparser.cpp index 7013276cd..d2e1b070b 100644 --- a/app/common/commandlineparser.cpp +++ b/app/common/commandlineparser.cpp @@ -34,11 +34,11 @@ CommandLineParser::~CommandLineParser() } } -const CommandLineParser::Option *CommandLineParser::AddOption(const QStringList &strings, const QString &description, bool takes_arg, const QString &arg_placeholder) +const CommandLineParser::Option *CommandLineParser::AddOption(const QStringList &strings, const QString &description, bool takes_arg, const QString &arg_placeholder, bool hidden) { Option* o = new Option(); - options_.append({strings, description, o, takes_arg, arg_placeholder}); + options_.append({strings, description, o, takes_arg, arg_placeholder, hidden}); return o; } @@ -140,6 +140,10 @@ void CommandLineParser::PrintHelp(const char* filename) printf("Usage: %s [options] %s\n\n", basename, positional_args.toUtf8().constData()); foreach (const KnownOption& o, options_) { + if (o.hidden) { + continue; + } + QString all_args; for (int i=0; i