version switch works properly now.

version has precedence over help as well as over missing parameters.
This commit is contained in:
King_DuckZ 2013-08-22 12:21:03 +02:00
parent f307656bda
commit cb1f4fffd9

View file

@ -75,12 +75,19 @@ namespace {
boost::program_options::store(boost::program_options::command_line_parser(parArgc, parArgv).options(commandLine).positional(positionals).run(), parVarMap);
boost::program_options::notify(parVarMap);
bool shownSomething = false;
if (parVarMap.count("help") or parVarMap.count("source-lang") != 1 or
parVarMap.count("dest-lang") != 1 or parVarMap.count("word") == 0) {
std::cout << desc << "\n";
shownSomething = true;
if (parVarMap.count("version") == 0) {
const bool enoughParams = static_cast<bool>(
parVarMap.count("source-lang") == 1 and
parVarMap.count("dest-lang") == 1 and
parVarMap.count("word") > 0
);
if (parVarMap.count("help") or not enoughParams) {
std::cout << desc << "\n";
shownSomething = true;
}
}
else if (parVarMap.count("version")) {
else {
std::cout << APP_NAME << " v" << APP_VER_MAJOR << "." << APP_VER_MINOR << "." << APP_VER_REVISION << "\n";
std::cout << "rev: " << APP_VER_GIT << "\n";
shownSomething = true;