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:
34
src/main.cpp
34
src/main.cpp
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user