mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Report Filters
- Report filters are now properly loaded and injected into the argument list.
This commit is contained in:
parent
b58438bdd4
commit
42ead6b34d
4 changed files with 47 additions and 3 deletions
|
@ -168,7 +168,7 @@ void Arguments::capture (int argc, const char** argv)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Add a pair with a category of "".
|
||||
// Append a pair with a category of "".
|
||||
void Arguments::capture (const std::string& arg)
|
||||
{
|
||||
std::vector <std::string> parts;
|
||||
|
@ -184,6 +184,36 @@ void Arguments::capture (const std::string& arg)
|
|||
categorize ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Prepend a pair with a category of "".
|
||||
void Arguments::capture_first (const std::string& arg)
|
||||
{
|
||||
// Break the new argument into parts that comprise a series.
|
||||
std::vector <std::pair <std::string, std::string> > series;
|
||||
|
||||
std::vector <std::string> parts;
|
||||
if (is_multipart (arg, parts))
|
||||
{
|
||||
std::vector <std::string>::iterator part;
|
||||
for (part = parts.begin (); part != parts.end (); ++part)
|
||||
series.push_back (std::make_pair (*part, ""));
|
||||
}
|
||||
else
|
||||
series.push_back (std::make_pair (arg, ""));
|
||||
|
||||
// Locate an appropriate place to insert the series. This would be
|
||||
// immediately after the program and command arguments.
|
||||
std::vector <std::pair <std::string, std::string> >::iterator position;
|
||||
for (position = this->begin (); position != this->end (); ++position)
|
||||
if (position->second != "program" &&
|
||||
position->second != "command")
|
||||
break;
|
||||
|
||||
this->insert (position, series.begin (), series.end ());
|
||||
|
||||
categorize ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Add a pair for every word from std::cin, with a category of "".
|
||||
void Arguments::append_stdin ()
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
|
||||
void capture (int, const char**);
|
||||
void capture (const std::string&);
|
||||
void capture_first (const std::string&);
|
||||
void categorize ();
|
||||
|
||||
void append_stdin ();
|
||||
|
|
|
@ -82,6 +82,13 @@ int CmdCustom::execute (std::string& output)
|
|||
split (sortOrder, reportSort, ',');
|
||||
validateSortColumns (sortOrder);
|
||||
|
||||
// Prepend the argument list with those from the report filter.
|
||||
std::vector <std::string> filterArgs;
|
||||
split (filterArgs, reportFilter, ' ');
|
||||
std::vector <std::string>::iterator arg;
|
||||
for (arg = filterArgs.begin (); arg != filterArgs.end (); ++ arg)
|
||||
context.args.capture_first (*arg);
|
||||
|
||||
// Load the data.
|
||||
// TODO Replace with TDB2.
|
||||
std::vector <Task> tasks;
|
||||
|
|
|
@ -28,12 +28,13 @@
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 11;
|
||||
use Test::More tests => 12;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'subst.rc')
|
||||
{
|
||||
print $fh "data.location=.\n";
|
||||
print $fh "data.location=.\n",
|
||||
"regex=off\n";
|
||||
close $fh;
|
||||
ok (-r 'subst.rc', 'Created subst.rc');
|
||||
}
|
||||
|
@ -68,6 +69,11 @@ qx{../src/task rc:subst.rc 1 /bbb//};
|
|||
$output = qx{../src/task rc:subst.rc info 1};
|
||||
like ($output, qr/aaa ccc/, 'word deletion in description');
|
||||
|
||||
# Regexes
|
||||
qx{../src/task rc:subst.rc rc.regex:on 1 "/c(c)./C/"};
|
||||
$output = qx{../src/task rc:subst.rc info 1};
|
||||
like ($output, qr/aaa cCc/, 'regex');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue