Permalink
Browse files

#9 TI-1: Add informative output to undo command

  • Loading branch information...
lauft committed Jul 19, 2018
1 parent 2dfc170 commit 86258cdb93c411f9e14859984b78ad9e63adbe6b
Showing with 13 additions and 3 deletions.
  1. +11 −1 src/commands/CmdUndo.cpp
  2. +1 −1 src/commands/commands.h
  3. +1 −1 src/init.cpp
@@ -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 ();

@@ -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
{
@@ -46,6 +51,11 @@ int CmdUndo (Database& database)
// Select database...
// Rollback action...
}

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

return 0;
@@ -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& );
@@ -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);

0 comments on commit 86258cd

Please sign in to comment.