Skip to content

Commit

Permalink
#9 TI-1: Add informative output to undo command
Browse files Browse the repository at this point in the history
  • Loading branch information
lauft committed Jul 19, 2018
1 parent 2dfc170 commit 86258cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/commands/CmdUndo.cpp
Expand Up @@ -27,9 +27,10 @@
#include <commands.h>
#include <timew.h>
#include <iostream>
#include <format.h>

////////////////////////////////////////////////////////////////////////////////
int CmdUndo (Database& database)
int CmdUndo (Rules& rules, Database& database)
{
Transaction transaction = database.popLastTransaction ();

Expand All @@ -38,6 +39,10 @@ int CmdUndo (Database& database)
if (actions.empty ())
{
// No (more) undoing...
if (rules.getBoolean ("verbose"))
{
std::cout << "Nothing to undo." << std::endl;
}
}
else
{
Expand All @@ -46,6 +51,11 @@ int CmdUndo (Database& database)
// Select database...
// Rollback action...
}

if (rules.getBoolean ("verbose"))
{
std::cout << "Undo" << std::endl;
}
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commands.h
Expand Up @@ -58,7 +58,7 @@ int CmdStop (const CLI&, Rules&, Database& );
int CmdTag (const CLI&, Rules&, Database& );
int CmdTags (const CLI&, Rules&, Database& );
int CmdTrack (const CLI&, Rules&, Database& );
int CmdUndo ( Database& );
int CmdUndo ( Rules&, Database& );
int CmdUntag (const CLI&, Rules&, Database& );

int CmdChartDay (const CLI&, Rules&, Database& );
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Expand Up @@ -285,7 +285,7 @@ int dispatchCommand (
else if (command == "tag") status = CmdTag (cli, rules, database );
else if (command == "tags") status = CmdTags (cli, rules, database );
else if (command == "track") status = CmdTrack (cli, rules, database );
else if (command == "undo") status = CmdUndo ( database );
else if (command == "undo") status = CmdUndo ( rules, database );
else if (command == "untag") status = CmdUntag (cli, rules, database );
else if (command == "week") status = CmdChartWeek (cli, rules, database );
else status = CmdReport (cli, rules, database, extensions);
Expand Down

0 comments on commit 86258cd

Please sign in to comment.