mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
add initial bulk run from pre-commit over all files
This commit is contained in:
parent
665aeeef61
commit
93356b39c3
418 changed files with 21354 additions and 23858 deletions
|
@ -28,71 +28,63 @@
|
|||
// cmake.h include header must come first
|
||||
|
||||
#include <CmdUnique.h>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <format.h>
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdUnique::CmdUnique ()
|
||||
{
|
||||
_keyword = "_unique";
|
||||
_usage = "task <filter> _unique <attribute>";
|
||||
_description = "Generates lists of unique attribute values";
|
||||
_read_only = true;
|
||||
_displays_id = true;
|
||||
_needs_gc = true;
|
||||
_uses_context = false;
|
||||
_accepts_filter = true;
|
||||
CmdUnique::CmdUnique() {
|
||||
_keyword = "_unique";
|
||||
_usage = "task <filter> _unique <attribute>";
|
||||
_description = "Generates lists of unique attribute values";
|
||||
_read_only = true;
|
||||
_displays_id = true;
|
||||
_needs_gc = true;
|
||||
_uses_context = false;
|
||||
_accepts_filter = true;
|
||||
_accepts_modifications = false;
|
||||
_accepts_miscellaneous = true;
|
||||
_category = Command::Category::internal;
|
||||
_category = Command::Category::internal;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdUnique::execute (std::string& output)
|
||||
{
|
||||
int CmdUnique::execute(std::string& output) {
|
||||
// Apply filter.
|
||||
Filter filter;
|
||||
filter.disableSafety ();
|
||||
std::vector <Task> filtered;
|
||||
filter.subset (filtered);
|
||||
filter.disableSafety();
|
||||
std::vector<Task> filtered;
|
||||
filter.subset(filtered);
|
||||
|
||||
// Find <attribute>.
|
||||
std::string attribute {};
|
||||
std::string attribute{};
|
||||
|
||||
// Just the first arg.
|
||||
auto words = Context::getContext ().cli2.getWords ();
|
||||
if (words.size () == 0)
|
||||
throw std::string ("An attribute must be specified. See 'task _columns'.");
|
||||
auto words = Context::getContext().cli2.getWords();
|
||||
if (words.size() == 0) throw std::string("An attribute must be specified. See 'task _columns'.");
|
||||
attribute = words[0];
|
||||
|
||||
std::string canonical;
|
||||
if (! Context::getContext ().cli2.canonicalize (canonical, "attribute", attribute))
|
||||
throw std::string ("You must specify an attribute or UDA.");
|
||||
if (!Context::getContext().cli2.canonicalize(canonical, "attribute", attribute))
|
||||
throw std::string("You must specify an attribute or UDA.");
|
||||
|
||||
// Find the unique set of matching tasks.
|
||||
std::set <std::string> 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));
|
||||
std::set<std::string> 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 values.
|
||||
for (auto& value : values)
|
||||
output += value + '\n';
|
||||
for (auto& value : values) output += value + '\n';
|
||||
|
||||
Context::getContext ().headers.clear ();
|
||||
Context::getContext().headers.clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue