From eb06efc92adc5db33c6776d0651473354a62301b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 11 Apr 2016 17:17:56 -0400 Subject: [PATCH] CmdContinue: Handles case where there is no previous interval to restart --- src/commands/CmdContinue.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/commands/CmdContinue.cpp b/src/commands/CmdContinue.cpp index 4df8cb19..9811c9c3 100644 --- a/src/commands/CmdContinue.cpp +++ b/src/commands/CmdContinue.cpp @@ -35,23 +35,29 @@ int CmdContinue ( Database& database) { auto latest = getLatestInterval (database); - - if (latest.isStarted () && - latest.isEnded ()) + if (! latest.empty ()) { - // Open an identical interval. - latest.start ({}); - latest.end ({0}); + if (latest.isStarted () && + latest.isEnded ()) + { + // Open an identical interval. + latest.start ({}); + latest.end ({0}); - // Update database. - database.addInterval (latest); + // Update database. + database.addInterval (latest); - // User feedback. - std::cout << intervalSummarize (rules, latest); + // User feedback. + std::cout << intervalSummarize (rules, latest); + } + else + { + std::cout << "There is already active tracking.\n"; + } } else { - std::cout << "There is already active tracking.\n"; + std::cout << "There is no previous tracking to continue.\n"; } return 0;