Skip to content

Commit 7b2fd1c

Browse files
committed
CLI: Reserve arguments that start with ':' for hints
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 #348 Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
1 parent 6fe15d2 commit 7b2fd1c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/CLI.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,18 @@ void CLI::canonicalizeNames ()
465465
}
466466

467467
// Hints.
468-
else if (exactMatch ("hint", raw) ||
469-
canonicalize (canonical, "hint", raw))
468+
else if (0 == raw.compare (0, 1, ":"))
470469
{
471-
a.attribute ("canonical", canonical);
472-
a.tag ("HINT");
470+
if (exactMatch ("hint", raw) ||
471+
canonicalize (canonical, "hint", raw))
472+
{
473+
a.attribute ("canonical", canonical);
474+
a.tag ("HINT");
475+
}
476+
else
477+
{
478+
throw format ("'{1}' is an invalid hint.", raw);
479+
}
473480
}
474481

475482
// Extensions.

test/cli.t

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ class TestCLI(TestCase):
103103
code, out, err = self.t.runError("bogus")
104104
self.assertIn("'bogus' is not a timew command. See 'timew help'.", err)
105105

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

107112
if __name__ == "__main__":
108113
from simpletap import TAPTestRunner

0 commit comments

Comments
 (0)