From 02b91a94fcd583fbf35e82a7e9fb4eb925df695f Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 22 Jun 2015 11:55:55 -0400 Subject: [PATCH] CLI2: Fixed bug recognizing command names - If a command is found via canonicalization, but that command is also an exact match for an attribute, then it is not a command. --- src/CLI2.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 34bf594a6..c26292725 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -798,8 +798,16 @@ bool CLI2::findCommand () { for (auto& a : _args) { + std::string raw = a.attribute ("raw"); std::string canonical; - if (canonicalize (canonical, "cmd", a.attribute ("raw"))) + + // If the arg canonicalized to a 'cmd', but is also not an exact match + // for an 'attribute', proceed. Example: + // task project=foo list + // ^cmd ^cmd + // ^attribute + if (canonicalize (canonical, "cmd", raw) && + ! exactMatch ("attribute", raw)) { a.attribute ("canonical", canonical); a.tag ("CMD");