diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-08-31 09:24:05 +0530 |
---|---|---|
committer | Pranav Kant <pranavk@collabora.co.uk> | 2017-08-31 09:24:44 +0530 |
commit | 67bf4dc212aa384e4ccbc4b48afdd62964f9a2a9 (patch) | |
tree | 59523f8c4bfea37efaa5af9715fd5b885dce458c /tools/Config.cpp | |
parent | wsd: fix incorrect password hash format written to config file (diff) | |
download | online-67bf4dc212aa384e4ccbc4b48afdd62964f9a2a9.tar.gz online-67bf4dc212aa384e4ccbc4b48afdd62964f9a2a9.zip |
loolconfig: print help information from option set
Change-Id: Ifbc5ca72d17444b8fdefb7093744cbead1922a31
Diffstat (limited to 'tools/Config.cpp')
-rw-r--r-- | tools/Config.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/tools/Config.cpp b/tools/Config.cpp index 40bbddd1be..bf8c1e28ab 100644 --- a/tools/Config.cpp +++ b/tools/Config.cpp @@ -19,6 +19,7 @@ #include <Poco/Exception.h> #include <Poco/Util/Application.h> +#include <Poco/Util/HelpFormatter.h> #include <Poco/Util/Option.h> #include <Poco/Util/OptionSet.h> #include <Poco/Util/XMLConfiguration.h> @@ -26,6 +27,7 @@ #include "Util.hpp" using Poco::Util::Application; +using Poco::Util::HelpFormatter; using Poco::Util::Option; using Poco::Util::OptionSet; using Poco::Util::XMLConfiguration; @@ -71,7 +73,12 @@ std::string Config::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml"; void Config::displayHelp() { - std::cout << "loolconfig - Configuration tool for LibreOffice Online." << std::endl + HelpFormatter helpFormatter(options()); + helpFormatter.setCommand(commandName()); + helpFormatter.setHeader("Configuration tool for LibreOffice Online."); + helpFormatter.setUsage("OPTIONS COMMAND"); + helpFormatter.format(std::cout); + std::cout << std::endl << "Commands:" << std::endl << " set-admin-password" << std::endl; } @@ -80,25 +87,29 @@ void Config::defineOptions(OptionSet& optionSet) { Application::defineOptions(optionSet); - optionSet.addOption(Option("help", "", "Config helper tool to set loolwsd configuration") + // global options + optionSet.addOption(Option("help", "", "Prints help information") .required(false) .repeatable(false)); - optionSet.addOption(Option("pwd-salt-length", "", "Length of the salt to use to hash password") + optionSet.addOption(Option("config-file", "", "Specify configuration file path manually.") + .required(false) + .repeatable(false) + .argument("path")); + + // Command specific option + optionSet.addOption(Option("pwd-salt-length", "", "Length of the salt to use to hash password. To be used with set-admin-password command.") .required(false) .repeatable(false). argument("number")); - optionSet.addOption(Option("pwd-iterations", "", "Number of iterations to do in PKDBF2 password hashing") + optionSet.addOption(Option("pwd-iterations", "", "Number of iterations to do in PKDBF2 password hashing. To be used with set-admin-password command.") .required(false) .repeatable(false) .argument("number")); - optionSet.addOption(Option("pwd-hash-length", "", "Length of password hash to generate") + optionSet.addOption(Option("pwd-hash-length", "", "Length of password hash to generate. To be used with set-admin-password command.") .required(false) .repeatable(false) .argument("number")); - optionSet.addOption(Option("config-file", "", "Specify configuration file path manually.") - .required(false) - .repeatable(false) - .argument("path")); + } void Config::handleOption(const std::string& optionName, const std::string& optionValue) |