mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
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:
parent
ecb8aa447c
commit
f1b3b3bb72
4 changed files with 47 additions and 29 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue