Skip to content

Commit

Permalink
CLI: Reserve arguments that start with ':' for hints
Browse files Browse the repository at this point in the history
Currently, any argument that starts with ':' that isn't a known hint
will be treated as a tag. After this change, an error is produced.

Hopefully there were not users who were using tags that start with a
colon...

Closes GothenburgBitFactory#348
  • Loading branch information
sruffell committed Aug 13, 2020
1 parent 566d14b commit e881d66
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/CLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,18 @@ void CLI::canonicalizeNames ()
}

// Hints.
else if (exactMatch ("hint", raw) ||
canonicalize (canonical, "hint", raw))
else if (0 == raw.compare (0, 1, ":"))
{
a.attribute ("canonical", canonical);
a.tag ("HINT");
if (exactMatch ("hint", raw) ||
canonicalize (canonical, "hint", raw))
{
a.attribute ("canonical", canonical);
a.tag ("HINT");
}
else
{
throw format ("'{1}' is an invalid hint.", raw);
}
}

// Extensions.
Expand Down
5 changes: 5 additions & 0 deletions test/cli.t
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ class TestCLI(TestCase):
code, out, err = self.t.runError("bogus")
self.assertIn("'bogus' is not a timew command. See 'timew help'.", err)

def test_TimeWarrior_with_invalid_hint(self):
"""Call a non-existing TimeWarrior hint should be an error"""
code, out, err = self.t.runError("start :invalid_hint")
self.assertIn("':invalid_hint'", err)


if __name__ == "__main__":
from simpletap import TAPTestRunner
Expand Down

0 comments on commit e881d66

Please sign in to comment.