CmdClear: Propagated cli, rules, database

This commit is contained in:
Paul Beckingham 2016-05-07 00:10:12 -04:00
parent 97cf6dfddb
commit 0e23f222b9
3 changed files with 16 additions and 10 deletions

View file

@ -25,19 +25,25 @@
////////////////////////////////////////////////////////////////////////////////
#include <cmake.h>
#include <timew.h>
#include <iostream>
////////////////////////////////////////////////////////////////////////////////
int CmdClear ()
int CmdClear (
const CLI& cli,
Rules& rules,
Database& database)
{
std::cout << "[clear: allows removal of tags form intervals]\n";
auto filter = getFilter (cli);
if (! filter.range.started () &&
filter.tags ().size () == 0)
throw std::string ("The 'clear' command refuses to delete all your data.");
// TODO Parse interval.
// TODO Parser tags.
// TODO Load all data.
// TODO Apply filter.
// TODO For each interval.
// TODO Remove tags.
auto tracked = getTrackedIntervals (database, rules, filter);
auto extent = outerRange (tracked);
for (auto& interval : subset (extent, tracked))
std::cout << "# clear impacts " << interval.dump () << "\n";
return 0;
}

View file

@ -33,7 +33,7 @@
#include <Extensions.h>
int CmdCancel ( Rules&, Database& );
int CmdClear ( );
int CmdClear (const CLI&, Rules&, Database& );
int CmdConfig (const CLI&, Rules& );
int CmdContinue ( Rules&, Database& );
int CmdDefault ( Rules&, Database& );

View file

@ -227,7 +227,7 @@ int dispatchCommand (
// These signatures are æxpected to be all different, therefore no
// command to fn mapping.
if (command == "cancel") status = CmdCancel ( rules, database );
else if (command == "clear") status = CmdClear ( );
else if (command == "clear") status = CmdClear (cli, rules, database );
else if (command == "config") status = CmdConfig (cli, rules );
else if (command == "continue") status = CmdContinue ( rules, database );
else if (command == "day") status = CmdReportDay (cli, rules, database );