summaryrefslogtreecommitdiff
path: root/tools/Tool.cpp
diff options
context:
space:
mode:
authorAndras Timar <andras.timar@collabora.com>2018-05-09 12:27:30 +0200
committerMichael Meeks <michael.meeks@collabora.com>2018-05-09 15:27:38 +0200
commite2bc253bd9123b1659c0665f86fd0a1dc7c820ab (patch)
tree119409874a9044685862e6cccd982736e9a8e322 /tools/Tool.cpp
parent8481602061c06ec2b03d41a19e35ef47151a88e4 (diff)
loolconvert: print help if no args
Change-Id: I8f93e61fa73a17132842f8786557f81d049393a6 Reviewed-on: https://gerrit.libreoffice.org/54026 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'tools/Tool.cpp')
-rw-r--r--tools/Tool.cpp26
1 files changed, 20 insertions, 6 deletions
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;