From 1c87831cba055c78a5288f513679a781c1c62dd8 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 24 Jan 2010 20:28:35 +0000 Subject: added --version parameter --- src/options.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/options.cpp') diff --git a/src/options.cpp b/src/options.cpp index 6230483..c393c9f 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -37,6 +37,8 @@ #include #include "datatypes.h" +#include "version.h" + #include "options.h" #include "log.h" #include "authAlgoFactory.h" @@ -371,8 +373,14 @@ bool Options::parse(int argc, char* argv[]) std::string str(argv[i]); argc--; - if(str == "-h" || str == "--help") + if(str == "-h" || str == "--help") { + printUsage(); + return false; + } + else if(str == "-v" || str == "--version") { + printVersion(); return false; + } #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS) @@ -520,6 +528,19 @@ void Options::parse_post() dev_type_ = "tun"; } +void Options::printVersion() +{ +#if defined(ANYCTR_OPTIONS) + std::cout << "anytun-controld"; +#elif defined(ANYCONF_OPTIONS) + std::cout << "anytun-config"; +#else + std::cout << "anytun"; +#endif + std::cout << VERSION_STRING_0 << std::endl; + std::cout << VERSION_STRING_1 << std::endl; +} + void Options::printUsage() { std::cout << "USAGE:" << std::endl; @@ -533,6 +554,7 @@ void Options::printUsage() #endif std::cout << " [-h|--help] prints this..." << std::endl; + std::cout << " [-v|--version] print version info and exit" << std::endl; #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS) -- cgit v1.2.3