mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CmdUnique: Code cleanup
This commit is contained in:
parent
670a215743
commit
82cd74906b
1 changed files with 9 additions and 3 deletions
|
@ -63,7 +63,7 @@ int CmdUnique::execute (std::string& output)
|
||||||
filter.subset (filtered);
|
filter.subset (filtered);
|
||||||
|
|
||||||
// Find <attribute>.
|
// Find <attribute>.
|
||||||
std::string attribute = "";
|
std::string attribute {};
|
||||||
|
|
||||||
// Just the first arg.
|
// Just the first arg.
|
||||||
auto words = context.cli2.getWords ();
|
auto words = context.cli2.getWords ();
|
||||||
|
@ -75,17 +75,23 @@ int CmdUnique::execute (std::string& output)
|
||||||
if (! context.cli2.canonicalize (canonical, "attribute", attribute))
|
if (! context.cli2.canonicalize (canonical, "attribute", attribute))
|
||||||
throw std::string (STRING_CMD_UNIQUE_VALID);
|
throw std::string (STRING_CMD_UNIQUE_VALID);
|
||||||
|
|
||||||
// Find number of matching tasks.
|
// Find the unique set of matching tasks.
|
||||||
std::set <std::string> values;
|
std::set <std::string> values;
|
||||||
for (auto& task : filtered)
|
for (auto& task : filtered)
|
||||||
|
{
|
||||||
if (task.has (canonical))
|
if (task.has (canonical))
|
||||||
|
{
|
||||||
values.insert (task.get (canonical));
|
values.insert (task.get (canonical));
|
||||||
|
}
|
||||||
else if (canonical == "id" &&
|
else if (canonical == "id" &&
|
||||||
task.getStatus () != Task::deleted &&
|
task.getStatus () != Task::deleted &&
|
||||||
task.getStatus () != Task::completed)
|
task.getStatus () != Task::completed)
|
||||||
|
{
|
||||||
values.insert (format (task.id));
|
values.insert (format (task.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generate list of unique values.
|
// Generate list of values.
|
||||||
for (auto& value : values)
|
for (auto& value : values)
|
||||||
output += value + '\n';
|
output += value + '\n';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue