[Pkg-owncloud-commits] [owncloud-client] 247/498: clear error hint went wrongly use command line options

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:54 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 263fa5882bbac3f841274475f9545ab52c36b198
Author: Arthur Schiwon <blizzz at owncloud.com>
Date:   Fri Jul 3 16:01:24 2015 +0200

    clear error hint went wrongly use command line options
---
 src/gui/application.cpp | 22 ++++++++++++++--------
 src/gui/application.h   |  1 +
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/gui/application.cpp b/src/gui/application.cpp
index bdb6405..1e8fefd 100644
--- a/src/gui/application.cpp
+++ b/src/gui/application.cpp
@@ -351,19 +351,19 @@ void Application::parseOptions(const QStringList &options)
             if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
                _logFile = it.next();
             } else {
-                setHelp();
+                showHint("Log file not specified");
             }
         } else if (option == QLatin1String("--logdir")) {
             if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
                _logDir = it.next();
             } else {
-                setHelp();
+                showHint("Log dir not specified");
             }
         } else if (option == QLatin1String("--logexpire")) {
             if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
                 _logExpire = it.next().toInt();
             } else {
-                setHelp();
+                showHint("Log expiration not specified");
             }
         } else if (option == QLatin1String("--logflush")) {
             _logFlush = true;
@@ -371,17 +371,15 @@ void Application::parseOptions(const QStringList &options)
             if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
                 QString confDir = it.next();
                 if (!ConfigFile::setConfDir( confDir )) {
-                    std::cerr << "Invalid path passed to --confdir" << std::endl;
-                    std::exit(1);
+                    showHint("Invalid path passed to --confdir");
                 }
             } else {
-                showHelp();
+                showHint("Path for confdir not specified");
             }
         } else if (option == QLatin1String("--debug")) {
             _debugMode = true;
         } else {
-            setHelp();
-            break;
+            showHint("Unrecognized option '" + option.toStdString() + "'");
         }
     }
 }
@@ -430,6 +428,14 @@ void Application::showHelp()
     displayHelpText(helpText);
 }
 
+void Application::showHint(std::string errorHint)
+{
+    static QString binName = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
+    std::cerr << errorHint << std::endl;
+    std::cerr << "Try '" << binName.toStdString() << " --help' for more information" << std::endl;
+    std::exit(1);
+}
+
 bool Application::debugMode()
 {
     return _debugMode;
diff --git a/src/gui/application.h b/src/gui/application.h
index dddedff..27c8c82 100644
--- a/src/gui/application.h
+++ b/src/gui/application.h
@@ -56,6 +56,7 @@ public:
 
     bool giveHelp();
     void showHelp();
+    void showHint(std::string errorHint);
     bool debugMode();
 
     void showSettingsDialog();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list