[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - tools/Tool.cpp

Andras Timar andras.timar at collabora.com
Thu May 24 08:06:55 UTC 2018


 tools/Tool.cpp |   26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

New commits:
commit b259495fa980b31f6dfc80ec26e96eb9b3fd7d53
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>
    (cherry picked from commit e2bc253bd9123b1659c0665f86fd0a1dc7c820ab)
    Reviewed-on: https://gerrit.libreoffice.org/54052
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/tools/Tool.cpp b/tools/Tool.cpp
index d722a01b1..2480c0aa8 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