]> Some of my projects - AniAddCLI.git/commitdiff
Add version cli option.
authorAPTX <marek321@gmail.com>
Thu, 12 Jan 2012 23:53:43 +0000 (00:53 +0100)
committerAPTX <marek321@gmail.com>
Thu, 12 Jan 2012 23:53:43 +0000 (00:53 +0100)
main.cpp

index 34518cc278662ed55071f7367d5a41aed0bc8115..1365ff9daf95ac705570ef17bcbc6c6d356a23b7 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -80,6 +80,7 @@ int main(int argc, char *argv[])
        opts.addSection("Common options");
        opts.add("help", "Print this message");
        opts.alias("help", "h");
+       opts.add("version", "Print version information");
 //     opts.add("config", "Use this config file", QxtCommandOptions::ValueRequired);
 //     opts.alias("config", "c");
        opts.add("no-config", "Do not read config file");
@@ -122,7 +123,7 @@ int main(int argc, char *argv[])
 
        QTextStream cout(stdout, QIODevice::WriteOnly);
 
-       if (opts.count("help")) {
+       if (opts.count("help") || opts.count("version")) {
                cout << QCoreApplication::applicationName() << " v" << QCoreApplication::applicationVersion()
                         << " by " << QCoreApplication::organizationName() << endl;
                cout << "Built on " __DATE__ " at " __TIME__ " with Qt" QT_VERSION_STR ", Qxt" QXT_VERSION_STR;
@@ -134,6 +135,8 @@ int main(int argc, char *argv[])
                if (AniDBUdpClient::revision())
                        cout << "AniDBUdpClient revision " << AniDBUdpClient::revision() << "." << endl;
                cout << "Running with Qt" << qVersion() << ", Qxt" << qxtVersion() << endl;
+               if (opts.count("version"))
+                       return -1;
                cout << endl;
                opts.showUsage();
                return -1;