Skip to content

Commit

Permalink
add --version|-v command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrocha committed Jun 13, 2019
1 parent a9e3950 commit 598582e
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/app/main.cpp
Expand Up @@ -113,6 +113,28 @@ typedef SInt32 SRefCon;
#include "qgsopenclutils.h"
#endif

/**
* Print QGIS version
*/
void version( )
{
QStringList msg;

msg
<< QStringLiteral( "QGIS " ) << VERSION << QStringLiteral( " '" ) << RELEASE_NAME << QStringLiteral( "' (" )
<< QGSVERSION << QStringLiteral( ")\n" );

#ifdef Q_OS_WIN
MessageBox( nullptr,
msg.join( QString() ).toLocal8Bit().constData(),
"QGIS version",
MB_OK );
#else
std::cerr << msg.join( QString() ).toLocal8Bit().constData();
#endif

} // version()

/**
* Print usage text
*/
Expand All @@ -121,8 +143,6 @@ void usage( const QString &appName )
QStringList msg;

msg
<< QStringLiteral( "QGIS - " ) << VERSION << QStringLiteral( " '" ) << RELEASE_NAME << QStringLiteral( "' (" )
<< QGSVERSION << QStringLiteral( ")\n" )
<< QStringLiteral( "QGIS is a user friendly Open Source Geographic Information System.\n" )
<< QStringLiteral( "Usage: " ) << appName << QStringLiteral( " [OPTION] [FILE]\n" )
<< QStringLiteral( " OPTION:\n" )
Expand Down Expand Up @@ -605,6 +625,11 @@ int main( int argc, char *argv[] )
usage( args[0] );
return 2;
}
else if ( arg == QLatin1String( "--version" ) || arg == QLatin1String( "-v" ) )
{
version();
return EXIT_SUCCESS;
}
else if ( arg == QLatin1String( "--nologo" ) || arg == QLatin1String( "-n" ) )
{
myHideSplash = true;
Expand Down

0 comments on commit 598582e

Please sign in to comment.