Refactor CmdDefault

- restore original command behaviour:return exit code 0 if tracking is active, 1 if not
- show welcome screen on first run
- add/update tests
This commit is contained in:
Thomas Lauf 2018-01-05 23:34:16 +01:00
parent ecb8aa447c
commit f1b3b3bb72
4 changed files with 47 additions and 29 deletions

View file

@ -34,33 +34,39 @@ int CmdDefault (Rules& rules, Database& database)
{
// Load the most recent interval, summarize and display.
auto interval = getLatestInterval (database);
if (interval.range.is_open ())
{
if (rules.getBoolean ("verbose"))
std::cout << intervalSummarize (database, rules, interval);
}
else
{
if (rules.getBoolean ("verbose"))
{
if (rules.getBoolean ("temp.shiny"))
std::cout << '\n'
<< "Welcome to Timewarrior.\n"
<< '\n'
<< "There is built-in help:\n"
<< " timew help\n"
<< " timew help <command>\n"
<< " (and more)\n"
<< '\n'
<< "There is a fully-detailed man page:\n"
<< " man timew\n"
<< '\n';
else
std::cout << "There is no active time tracking.\n";
std::cout << intervalSummarize (database, rules, interval);
}
return 0;
}
return 0;
if (rules.getBoolean ("temp.shiny"))
{
std::cout << '\n'
<< "Welcome to Timewarrior.\n"
<< '\n'
<< "There is built-in help:\n"
<< " timew help\n"
<< " timew help <command>\n"
<< " (and more)\n"
<< '\n'
<< "There is a fully-detailed man page:\n"
<< " man timew\n"
<< '\n';
return 0;
}
if (rules.getBoolean ("verbose"))
{
std::cout << "There is no active time tracking.\n";
}
return 1;
}
////////////////////////////////////////////////////////////////////////////////