Add --version option

master
Kahrl 2013-09-25 04:47:44 +02:00
parent f0edd88dff
commit 5dce44ec5e
3 changed files with 20 additions and 0 deletions

View File

@ -37,6 +37,9 @@ Disable main menu
\-\-help \-\-help
Show allowed options Show allowed options
.TP .TP
\-\-version
Show version information
.TP
\-\-logfile <value> \-\-logfile <value>
Set logfile path (debug.txt) Set logfile path (debug.txt)
.TP .TP

View File

@ -31,6 +31,9 @@ Set gameid
\-\-help \-\-help
Show allowed options Show allowed options
.TP .TP
\-\-version
Show version information
.TP
\-\-logfile <value> \-\-logfile <value>
Set logfile path (debug.txt) Set logfile path (debug.txt)
.TP .TP

View File

@ -772,6 +772,8 @@ int main(int argc, char *argv[])
std::map<std::string, ValueSpec> allowed_options; std::map<std::string, ValueSpec> allowed_options;
allowed_options.insert(std::make_pair("help", ValueSpec(VALUETYPE_FLAG, allowed_options.insert(std::make_pair("help", ValueSpec(VALUETYPE_FLAG,
_("Show allowed options")))); _("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, allowed_options.insert(std::make_pair("config", ValueSpec(VALUETYPE_STRING,
_("Load configuration from specified file")))); _("Load configuration from specified file"))));
allowed_options.insert(std::make_pair("port", ValueSpec(VALUETYPE_STRING, allowed_options.insert(std::make_pair("port", ValueSpec(VALUETYPE_STRING,
@ -844,6 +846,18 @@ int main(int argc, char *argv[])
return cmd_args.getFlag("help") ? 0 : 1; 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 Low-level initialization
*/ */