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.
This commit is contained in:
Paul Beckingham
2012-01-16 22:44:59 -05:00
parent 15d25d4fdf
commit fe467640ca

View File

@@ -46,6 +46,7 @@ Context context;
#define srand(x) srandom(x) #define srand(x) srandom(x)
#endif #endif
////////////////////////////////////////////////////////////////////////////////
int main (int argc, const char** argv) int main (int argc, const char** argv)
{ {
// Set up randomness. // Set up randomness.
@@ -59,23 +60,30 @@ int main (int argc, const char** argv)
int status = 0; int status = 0;
try if (argc == 2 && !strcmp (argv[1], "--version"))
{ {
status = context.initialize (argc, argv); std::cout << VERSION << "\n";
if (status == 0)
status = context.run ();
} }
else
catch (std::string& error)
{ {
std::cout << error << "\n"; try
status = -1; {
} status = context.initialize (argc, argv);
if (status == 0)
status = context.run ();
}
catch (...) catch (std::string& error)
{ {
std::cerr << STRING_UNKNOWN_ERROR << "\n"; std::cout << error << "\n";
status = -2; status = -1;
}
catch (...)
{
std::cerr << STRING_UNKNOWN_ERROR << "\n";
status = -2;
}
} }
return status; return status;