CmdUnique: Converted to use CLI2::getWords

This commit is contained in:
Paul Beckingham
2015-08-22 11:02:35 -04:00
parent 908451cbf7
commit f850e0946b

View File

@@ -42,7 +42,7 @@ CmdUnique::CmdUnique ()
_keyword = "_unique"; _keyword = "_unique";
_usage = "task <filter> _unique <attribute>"; _usage = "task <filter> _unique <attribute>";
_description = STRING_CMD_UNIQUE_USAGE; _description = STRING_CMD_UNIQUE_USAGE;
_read_only = false; _read_only = true;
_displays_id = true; _displays_id = true;
_needs_gc = true; _needs_gc = true;
_uses_context = true; _uses_context = true;
@@ -63,20 +63,12 @@ int CmdUnique::execute (std::string& output)
// Find <attribute>. // Find <attribute>.
std::string attribute = ""; std::string attribute = "";
for (auto& a : context.cli2._args)
{
if ((a._lextype == Lexer::Type::word ||
a._lextype == Lexer::Type::dom) &&
a.hasTag ("MODIFICATION"))
{
// Stop at first matching arg.
attribute = a.attribute ("raw");
break;
}
}
if (attribute == "") // Just the first arg.
auto words = context.cli2.getWords ();
if (words.size () == 0)
throw std::string (STRING_CMD_UNIQUE_MISSING); throw std::string (STRING_CMD_UNIQUE_MISSING);
attribute = words[0];
std::string canonical; std::string canonical;
if (! context.cli2.canonicalize (canonical, "attribute", attribute)) if (! context.cli2.canonicalize (canonical, "attribute", attribute))