From 9d53702202c74de8d9dc5794312c8f20d2232312 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 19 Apr 2018 18:55:07 +0200 Subject: Update CommandLine help --- src/commandline.cpp | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/commandline.cpp b/src/commandline.cpp index 6f227c0..bb636f2 100644 --- a/src/commandline.cpp +++ b/src/commandline.cpp @@ -12,12 +12,30 @@ #include #include -void printOption(const QCommandLineOption &option) +inline std::string optionText(const QStringList &opts) { - std::cout << "- " - << std::setw(20) << std::left << option.names().join(", ").toStdString() - << std::setw(40) << std::left << option.description().toStdString() - << std::setw(30) << std::left << option.defaultValues().join(", ").toStdString() + std::string r; + for(auto i = opts.constBegin(); i != opts.constEnd(); ) { + if(i->length() == 1) { + r.append("-" + i->toStdString()); + } else { + r.append("--" + i->toStdString()); + } + + ++i; + if(i != opts.constEnd()) { + r.append(", "); + } + } + return r; +} + +inline void printOption(const QCommandLineOption &option) +{ + std::cout << " " + << std::setw(18) << std::left << optionText(option.names()) + << std::setw(32) << std::left << option.description().toStdString() + << std::setw(18) << std::left << option.defaultValues().join(", ").toStdString() << std::endl; } @@ -36,10 +54,10 @@ CommandLine::CommandLine() : QCommandLineParser() , helpOption(addHelpOption()) , versionOption(addVersionOption()) - , buildOption("build", "Show build information.") - , configOption({ "c", "config" }, "Set configuration file.", "path", Configuration::defaultUserConfigLocation()) - , profileOption({ "p", "profile" }, "Use this profile.", "profile", "") - , socketOption("socket", "Local server socket", "name", socketPath()) + , buildOption("build", "Displays build information.") + , configOption({ "c", "config" }, "Sets configuration file.", "path", Configuration::defaultUserConfigLocation()) + , profileOption({ "p", "profile" }, "Sets default profile.", "profile", "") + , socketOption("socket", "Sets local socket.", "name", socketPath()) , newWindowOption("in-new-window", "Open URL in new window") { setApplicationDescription("yet another no-frills browser"); @@ -103,6 +121,7 @@ void CommandLine::printHelp(int exitCode) std::cout << "You can also overwrite configuration options using the syntax: " << std::endl << "--browser.setting.path=value" << std::endl + << "More information on available keys can be found on the manual page." << std::endl << std::endl; std::cout << "Arguments: " << std::endl; -- cgit v1.2.1