diff --git a/src/commands/CmdTag.cpp b/src/commands/CmdTag.cpp index 89e48fc7..623b92c2 100644 --- a/src/commands/CmdTag.cpp +++ b/src/commands/CmdTag.cpp @@ -41,6 +41,11 @@ int CmdTag ( std::set ids = cli.getIds (); std::vector tags = cli.getTags (); + if (tags.empty ()) + { + throw std::string ("At least one tag must be specified. See 'timew help tag'."); + } + // Load the data. // Note: There is no filter. Interval filter; diff --git a/test/tag.t b/test/tag.t index 814b8866..cc8a8c13 100755 --- a/test/tag.t +++ b/test/tag.t @@ -56,6 +56,12 @@ class TestTag(TestCase): code, out, err = self.t.runError("tag foo") self.assertIn("At least one ID must be specified.", err) + def test_should_fail_on_no_tags(self): + """No tags is an error""" + self.t("track yesterday for 1hour") + code, out, err = self.t.runError("tag @1") + self.assertIn("At least one tag must be specified.", err) + def test_add_tag_to_closed_interval(self): """Add a tag to an closed interval""" self.t("track yesterday for 1hour")