CLI2: Simplified logic for separating FILTER, MODIFICATION, MISCELLANEOUS args

This commit is contained in:
Paul Beckingham 2015-08-23 09:44:02 -04:00
parent 62a66bad9c
commit 274d3dddd0

View file

@ -628,7 +628,7 @@ void CLI2::prepareFilter ()
// Classify FILTER, MODIFICATION and MISCELLANEOUS args, based on CMD DNA. // Classify FILTER, MODIFICATION and MISCELLANEOUS args, based on CMD DNA.
bool changes = false; bool changes = false;
bool foundCommand = false; bool afterCommand = false;
for (auto& a : _args) for (auto& a : _args)
{ {
@ -637,7 +637,7 @@ void CLI2::prepareFilter ()
if (a.hasTag ("CMD")) if (a.hasTag ("CMD"))
{ {
foundCommand = true; afterCommand = true;
} }
else if (a.hasTag ("BINARY") || else if (a.hasTag ("BINARY") ||
a.hasTag ("RC") || a.hasTag ("RC") ||
@ -649,19 +649,18 @@ void CLI2::prepareFilter ()
// All MODIFICATION args appear after the command. // All MODIFICATION args appear after the command.
else if (cmd && else if (cmd &&
cmd->accepts_modifications () && cmd->accepts_modifications () &&
foundCommand) ! cmd->accepts_miscellaneous () &&
afterCommand)
{ {
a.tag ("MODIFICATION"); a.tag ("MODIFICATION");
changes = true; changes = true;
} }
// All MISCELLANEOUS args appear after the command.
else if (cmd && else if (cmd &&
cmd->accepts_miscellaneous () && cmd->accepts_miscellaneous () &&
! cmd->accepts_modifications () && ! cmd->accepts_modifications () &&
(foundCommand || (afterCommand ||
(! foundCommand && ! cmd->accepts_filter ()))
! cmd->accepts_filter ())))
{ {
a.tag ("MISCELLANEOUS"); a.tag ("MISCELLANEOUS");
changes = true; changes = true;
@ -669,10 +668,9 @@ void CLI2::prepareFilter ()
else if (cmd && else if (cmd &&
cmd->accepts_filter () && cmd->accepts_filter () &&
(! foundCommand || (! afterCommand ||
(foundCommand && (! cmd->accepts_modifications () &&
(! cmd->accepts_modifications () || ! cmd->accepts_miscellaneous ())))
! cmd->accepts_miscellaneous ()))))
{ {
a.tag ("FILTER"); a.tag ("FILTER");
changes = true; changes = true;