[Libreoffice-commits] online.git: tools/Tool.cpp
Andras Timar
andras.timar at collabora.com
Wed May 9 13:27:56 UTC 2018
tools/Tool.cpp | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
New commits:
commit e2bc253bd9123b1659c0665f86fd0a1dc7c820ab
Author: Andras Timar <andras.timar at collabora.com>
Date: Wed May 9 12:27:30 2018 +0200
loolconvert: print help if no args
Change-Id: I8f93e61fa73a17132842f8786557f81d049393a6
Reviewed-on: https://gerrit.libreoffice.org/54026
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/tools/Tool.cpp b/tools/Tool.cpp
index 196db4994..14d6f3fc8 100644
--- a/tools/Tool.cpp
+++ b/tools/Tool.cpp
@@ -41,6 +41,9 @@
/// Simple command-line tool for file format conversion.
class Tool: public Poco::Util::Application
{
+ // Display help information on the console
+ void displayHelp();
+
public:
Tool();
@@ -159,6 +162,15 @@ Tool::Tool() :
{
}
+void Tool::displayHelp()
+{
+ HelpFormatter helpFormatter(options());
+ helpFormatter.setCommand(commandName());
+ helpFormatter.setUsage("OPTIONS FILE(S)");
+ helpFormatter.setHeader("LibreOffice Online document converter tool.");
+ helpFormatter.format(std::cout);
+}
+
void Tool::defineOptions(OptionSet& optionSet)
{
Application::defineOptions(optionSet);
@@ -187,12 +199,7 @@ void Tool::handleOption(const std::string& optionName,
if (optionName == "help")
{
- HelpFormatter helpFormatter(options());
-
- helpFormatter.setCommand(commandName());
- helpFormatter.setUsage("OPTIONS");
- helpFormatter.setHeader("LibreOffice Online document converter tool.");
- helpFormatter.format(std::cout);
+ displayHelp();
std::exit(Application::EXIT_OK);
}
else if (optionName == "extension")
@@ -214,6 +221,13 @@ void Tool::handleOption(const std::string& optionName,
int Tool::main(const std::vector<std::string>& args)
{
+ if (args.empty())
+ {
+ std::cerr << "Nothing to do." << std::endl;
+ displayHelp();
+ return Application::EXIT_NOINPUT;
+ }
+
std::vector<std::unique_ptr<Thread>> clients(_numWorkers);
size_t chunk = (args.size() + _numWorkers - 1) / _numWorkers;
More information about the Libreoffice-commits
mailing list