From fe467640cad84d7f259f79b7f50462e6eec4dc24 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 16 Jan 2012 22:44:59 -0500 Subject: [PATCH] Bug #902 - 'task version' requires a .taskrc - Added special case support for '--version' which bypasses all configuration. Not documented. For extension prgorams like 'taskhelm', that need to determine whether taskwarrior is sufficiently current. --- src/main.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9416de6d5..709310697 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,6 +46,7 @@ Context context; #define srand(x) srandom(x) #endif +//////////////////////////////////////////////////////////////////////////////// int main (int argc, const char** argv) { // Set up randomness. @@ -59,23 +60,30 @@ int main (int argc, const char** argv) int status = 0; - try + if (argc == 2 && !strcmp (argv[1], "--version")) { - status = context.initialize (argc, argv); - if (status == 0) - status = context.run (); + std::cout << VERSION << "\n"; } - - catch (std::string& error) + else { - std::cout << error << "\n"; - status = -1; - } + try + { + status = context.initialize (argc, argv); + if (status == 0) + status = context.run (); + } - catch (...) - { - std::cerr << STRING_UNKNOWN_ERROR << "\n"; - status = -2; + catch (std::string& error) + { + std::cout << error << "\n"; + status = -1; + } + + catch (...) + { + std::cerr << STRING_UNKNOWN_ERROR << "\n"; + status = -2; + } } return status;