From 86258cdb93c411f9e14859984b78ad9e63adbe6b Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Thu, 19 Jul 2018 20:03:01 +0200 Subject: [PATCH] #9 TI-1: Add informative output to undo command --- src/commands/CmdUndo.cpp | 12 +++++++++++- src/commands/commands.h | 2 +- src/init.cpp | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/commands/CmdUndo.cpp b/src/commands/CmdUndo.cpp index d8beade1..a4acbaf5 100644 --- a/src/commands/CmdUndo.cpp +++ b/src/commands/CmdUndo.cpp @@ -27,9 +27,10 @@ #include #include #include +#include //////////////////////////////////////////////////////////////////////////////// -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; diff --git a/src/commands/commands.h b/src/commands/commands.h index 293ada75..40350139 100644 --- a/src/commands/commands.h +++ b/src/commands/commands.h @@ -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& ); diff --git a/src/init.cpp b/src/init.cpp index eceb5f01..5114be84 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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);