From fe24e078a4d167f004b0225d1403f6be57c73f69 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 28 Jan 2017 17:08:07 -0500 Subject: [PATCH] CmdUnique: Code cleanup --- src/commands/CmdUnique.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/commands/CmdUnique.cpp b/src/commands/CmdUnique.cpp index 9ebdae574..f215e3a58 100644 --- a/src/commands/CmdUnique.cpp +++ b/src/commands/CmdUnique.cpp @@ -63,7 +63,7 @@ int CmdUnique::execute (std::string& output) filter.subset (filtered); // Find . - std::string attribute = ""; + std::string attribute {}; // Just the first arg. auto words = context.cli2.getWords (); @@ -75,17 +75,23 @@ int CmdUnique::execute (std::string& output) if (! context.cli2.canonicalize (canonical, "attribute", attribute)) throw std::string (STRING_CMD_UNIQUE_VALID); - // Find number of matching tasks. + // Find the unique set of matching tasks. std::set values; for (auto& task : filtered) + { if (task.has (canonical)) + { values.insert (task.get (canonical)); + } else if (canonical == "id" && task.getStatus () != Task::deleted && task.getStatus () != Task::completed) + { values.insert (format (task.id)); + } + } - // Generate list of unique values. + // Generate list of values. for (auto& value : values) output += value + '\n';