diff options
author | Rogier Polak <rogier.l.a.polak@gmail.com> | 2007-03-18 13:54:40 +0000 |
---|---|---|
committer | Rogier Polak <rogier.l.a.polak@gmail.com> | 2007-03-18 13:54:40 +0000 |
commit | 1f1a5efaef0a10187592d29ea7b19e140e7a0196 (patch) | |
tree | 23c9fd117745d6387194e269b9182a9eaf65c3c7 /src/main.cpp | |
parent | 89468a178c60ef4e4d774708a3f6cf10b35f4b42 (diff) | |
download | mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.tar.gz mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.tar.bz2 mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.tar.xz mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.zip |
Added --version to the arguments, deleted the 'pink-code'.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 3cc32873..40106c5c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -122,11 +122,13 @@ struct Options */ Options(): printHelp(false), + printVersion(false), skipUpdate(false), chooseDefault(false) {}; bool printHelp; + bool printVersion; bool skipUpdate; bool chooseDefault; std::string username; @@ -334,6 +336,7 @@ void printHelp() << "tmw" << std::endl << std::endl << "Options: " << std::endl << " -h --help : Display this help" << std::endl + << " -v --version : Display the version" << std::endl << " -u --skipupdate : Skip the update process" << std::endl << " -U --username : Login with this username" << std::endl << " -P --password : Login with this password" << std::endl @@ -343,12 +346,22 @@ void printHelp() << std::endl; } +void printVersion() +{ +#ifdef PACKAGE_VERSION + std::cout << "The Mana World version " << PACKAGE_VERSION << std::endl; +#else + std::cout << "The Mana World version " << + "(local build?, PACKAGE_VERSION is not defined)" << std::endl; +#endif +} void parseOptions(int argc, char *argv[], Options &options) { - const char *optstring = "huU:P:Dp:C:"; + const char *optstring = "hvuU:P:Dp:C:"; const struct option long_options[] = { { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'v' }, { "skipupdate", no_argument, 0, 'u' }, { "username", required_argument, 0, 'U' }, { "password", required_argument, 0, 'P' }, @@ -370,6 +383,9 @@ void parseOptions(int argc, char *argv[], Options &options) case 'h': options.printHelp = true; break; + case 'v': + options.printVersion = true; + break; case 'u': options.skipUpdate = true; break; @@ -503,9 +519,6 @@ void mapLogin(Network *network, LoginData *loginData) /** Main */ int main(int argc, char *argv[]) { -#ifdef PACKAGE_VERSION - std::cout << "The Mana World v" << PACKAGE_VERSION << std::endl; -#endif logger = new Logger(); Options options; @@ -517,7 +530,11 @@ int main(int argc, char *argv[]) printHelp(); return 0; } - + else if (options.printVersion) + { + printVersion(); + return 0; + } // Initialize libxml2 and check for potential ABI mismatches between // compiled version and the shared library actually used. xmlInitParser(); |