[Pkg-owncloud-commits] [owncloud-client] 344/498: Application: Add a new command line switch --version.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Tue Aug 11 14:49:05 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 d284b48db465e6b5c3b5d9db23cd1dac663d758c
Author: Klaas Freitag <freitag at owncloud.com>
Date: Thu Jul 16 18:12:45 2015 +0200
Application: Add a new command line switch --version.
It simply prints the version of the client and exists.
---
src/gui/application.cpp | 21 ++++++++++++++++++++-
src/gui/application.h | 3 +++
src/gui/main.cpp | 4 ++++
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/gui/application.cpp b/src/gui/application.cpp
index 404a194..a2ddb94 100644
--- a/src/gui/application.cpp
+++ b/src/gui/application.cpp
@@ -89,6 +89,7 @@ Application::Application(int &argc, char **argv) :
_gui(0),
_theme(Theme::instance()),
_helpOnly(false),
+ _versionOnly(false),
_showLogWindow(false),
_logExpire(0),
_logFlush(false),
@@ -105,7 +106,7 @@ Application::Application(int &argc, char **argv) :
#endif
parseOptions(arguments());
//no need to waste time;
- if ( _helpOnly ) return;
+ if ( _helpOnly || _versionOnly ) return;
if (isRunning())
return;
@@ -346,6 +347,8 @@ void Application::parseOptions(const QStringList &options)
}
} else if (option == QLatin1String("--debug")) {
_debugMode = true;
+ } else if (option == QLatin1String("--version")) {
+ _versionOnly = true;
} else {
showHint("Unrecognized option '" + option.toStdString() + "'");
}
@@ -396,6 +399,17 @@ void Application::showHelp()
displayHelpText(helpText);
}
+void Application::showVersion()
+{
+ QString helpText;
+ QTextStream stream(&helpText);
+ stream << _theme->appName().toLatin1().constData()
+ << QLatin1String(" version ")
+ << _theme->version().toLatin1().constData() << endl;
+
+ displayHelpText(helpText);
+}
+
void Application::showHint(std::string errorHint)
{
static QString binName = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
@@ -492,6 +506,11 @@ bool Application::giveHelp()
return _helpOnly;
}
+bool Application::versionOnly()
+{
+ return _versionOnly;
+}
+
void Application::showSettingsDialog()
{
_gui->slotShowSettings();
diff --git a/src/gui/application.h b/src/gui/application.h
index 366d0fd..44fbfdd 100644
--- a/src/gui/application.h
+++ b/src/gui/application.h
@@ -58,6 +58,8 @@ public:
void showHelp();
void showHint(std::string errorHint);
bool debugMode();
+ bool versionOnly(); // only display the version?
+ void showVersion();
void showSettingsDialog();
@@ -94,6 +96,7 @@ private:
Theme *_theme;
bool _helpOnly;
+ bool _versionOnly;
// options from command line:
bool _showLogWindow;
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index b505fb0..1e259fd 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -59,6 +59,10 @@ int main(int argc, char **argv)
app.showHelp();
return 0;
}
+ if( app.versionOnly() ) {
+ app.showVersion();
+ return 0;
+ }
// check a environment variable for core dumps
#ifdef Q_OS_UNIX
--
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