diff --git a/src/commands/CmdStart.cpp b/src/commands/CmdStart.cpp index d6776948..c97d2fbc 100644 --- a/src/commands/CmdStart.cpp +++ b/src/commands/CmdStart.cpp @@ -36,23 +36,25 @@ int CmdStart ( Journal& journal) { auto verbose = rules.getBoolean ("verbose"); + const Datetime now {}; - auto filter = cli.getFilter (); - - auto now = Datetime (); + auto filter = cli.getFilter ({now, 0}); if (filter.start > now) + { throw std::string ("Time tracking cannot be set in the future."); + } + else if (!filter.is_started ()) + { + // The :all hint provides a filter that is neither started nor ended, which + // the start command cannot handle and we do not want to auto start it now. + throw std::string ("Interval start must be specified"); + } auto latest = getLatestInterval (database); journal.startTransaction (); - if (!filter.is_started ()) - { - filter.start = now; - } - // If the latest interval is open, close it. if (latest.is_open ()) { diff --git a/test/start.t b/test/start.t index aab36fac..af77e30f 100755 --- a/test/start.t +++ b/test/start.t @@ -263,6 +263,10 @@ class TestStart(TestCase): code, out, err = self.t.runError("start 2h ago proja") self.assertIn("The end of a date range must be after the start.", err) + def test_start_will_error_with_all_hint(self): + """Start will return an error when passed the :all hint""" + code, out, err = self.t.runError("start :all proja") + if __name__ == "__main__": from simpletap import TAPTestRunner