Add --version option
authorKahrl <kahrl@gmx.net>
Wed, 25 Sep 2013 02:47:44 +0000 (04:47 +0200)
committerKahrl <kahrl@gmx.net>
Sat, 28 Sep 2013 19:30:17 +0000 (21:30 +0200)
doc/minetest.6
doc/minetestserver.6
src/main.cpp

index 80991289e4f3e91fd172df3cc2aa32ae37f4be0d..d94c12cb6d6676a5a0f84061011fd2438cd7b038 100644 (file)
@@ -37,6 +37,9 @@ Disable main menu
 \-\-help
 Show allowed options
 .TP
+\-\-version
+Show version information
+.TP
 \-\-logfile <value>
 Set logfile path (debug.txt)
 .TP
index 35c4a1fe6db4687f3370a1b6665d51c7008c658e..1d4a5f838b37efc2acc6cadb8f6ea13ccb432ad9 100644 (file)
@@ -31,6 +31,9 @@ Set gameid
 \-\-help
 Show allowed options
 .TP
+\-\-version
+Show version information
+.TP
 \-\-logfile <value>
 Set logfile path (debug.txt)
 .TP
index 10547b71123d3b86c8daf0e24ed5cbe66f163e91..455138d5b690ac136f2f28900722ebb701f329d5 100644 (file)
@@ -772,6 +772,8 @@ int main(int argc, char *argv[])
        std::map<std::string, ValueSpec> allowed_options;
        allowed_options.insert(std::make_pair("help", ValueSpec(VALUETYPE_FLAG,
                        _("Show allowed options"))));
+       allowed_options.insert(std::make_pair("version", ValueSpec(VALUETYPE_FLAG,
+                       _("Show version information"))));
        allowed_options.insert(std::make_pair("config", ValueSpec(VALUETYPE_STRING,
                        _("Load configuration from specified file"))));
        allowed_options.insert(std::make_pair("port", ValueSpec(VALUETYPE_STRING,
@@ -843,6 +845,18 @@ int main(int argc, char *argv[])
 
                return cmd_args.getFlag("help") ? 0 : 1;
        }
+
+       if(cmd_args.getFlag("version"))
+       {
+#ifdef SERVER
+               dstream<<"minetestserver "<<minetest_version_hash<<std::endl;
+#else
+               dstream<<"Minetest "<<minetest_version_hash<<std::endl;
+               dstream<<"Using Irrlicht "<<IRRLICHT_SDK_VERSION<<std::endl;
+#endif
+               dstream<<"Build info: "<<minetest_build_info<<std::endl;
+               return 0;
+       }
        
        /*
                Low-level initialization