From a7eb32272c413c1ea4dc509cdc2149bacce9f009 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 13 Jul 2015 14:24:24 -0400 Subject: [PATCH] TW-1419: On add '-tag' is considered a tag removal, which makes no sense. --- ChangeLog | 1 + src/CLI2.cpp | 26 +++++++++++++++++++++----- src/CLI2.h | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index e57dac8c3..d727f9f77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ (thanks to Onion). - TW-1389 tw will import same UUID n-times if part of same import (thanks to Markus Beppler). +- TW-1419 On add '-tag' is considered a tag removal, which makes no sense. - TW-1430 Slashes in project names don't work (thanks to Richard Boß). - TW-1432 start/stop can be issued on completed tasks (thanks to Renato Alves). - TW-1440 "task import" from STDIN (thanks to Renato Alves). diff --git a/src/CLI2.cpp b/src/CLI2.cpp index a0145d95f..440341fed 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -481,9 +481,13 @@ void CLI2::lexArguments () //////////////////////////////////////////////////////////////////////////////// // Until the Lexer gains access to CLI2::_entities, it can only guess at whether -// a command is a DOM reference. Scan all Lexer::Type::dom arguments, and demote -// to Lexer::Type::word any unrecognized arguments. -void CLI2::demoteDOM () +// a command is a DOM reference. +// +// [1] Scan all Lexer::Type::dom arguments, and demote to Lexer::Type::word any +// unrecognized arguments. +// [2] Scan all MODIFICATION args for the 'add' and 'log' commands, and demote +// any Lexer::Type::Tag args with sense '-' to Lexer::Type::word. +void CLI2::demotion () { bool changes = false; @@ -498,11 +502,23 @@ void CLI2::demoteDOM () changes = true; } } + + if (a._lextype == Lexer::Type::tag && + a.attribute ("sign") == "-") + { + std::string command = getCommand (); + if (command == "add" || + command == "log") + { + a._lextype = Lexer::Type::word; + changes = true; + } + } } if (changes) if (context.config.getInteger ("debug.parser") >= 3) - context.debug (dump ("CLI2::analyze demoteDOM")); + context.debug (dump ("CLI2::analyze demotion")); } //////////////////////////////////////////////////////////////////////////////// @@ -516,7 +532,6 @@ void CLI2::analyze () _args.clear (); handleArg0 (); lexArguments (); - demoteDOM (); // Process _args. aliasExpansion (); @@ -527,6 +542,7 @@ void CLI2::analyze () throw std::string (STRING_TRIVIAL_INPUT); } + demotion (); canonicalizeNames (); } diff --git a/src/CLI2.h b/src/CLI2.h index 3b55e2940..c2d9b8054 100644 --- a/src/CLI2.h +++ b/src/CLI2.h @@ -89,7 +89,7 @@ public: private: void handleArg0 (); void lexArguments (); - void demoteDOM (); + void demotion (); void aliasExpansion (); void canonicalizeNames (); bool findCommand ();