mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-02 03:37:19 +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)
|
void Arguments::capture (const std::string& arg)
|
||||||
{
|
{
|
||||||
std::vector <std::string> parts;
|
std::vector <std::string> parts;
|
||||||
|
@ -184,6 +184,36 @@ void Arguments::capture (const std::string& arg)
|
||||||
categorize ();
|
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 "".
|
// Add a pair for every word from std::cin, with a category of "".
|
||||||
void Arguments::append_stdin ()
|
void Arguments::append_stdin ()
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
|
|
||||||
void capture (int, const char**);
|
void capture (int, const char**);
|
||||||
void capture (const std::string&);
|
void capture (const std::string&);
|
||||||
|
void capture_first (const std::string&);
|
||||||
void categorize ();
|
void categorize ();
|
||||||
|
|
||||||
void append_stdin ();
|
void append_stdin ();
|
||||||
|
|
|
@ -82,6 +82,13 @@ int CmdCustom::execute (std::string& output)
|
||||||
split (sortOrder, reportSort, ',');
|
split (sortOrder, reportSort, ',');
|
||||||
validateSortColumns (sortOrder);
|
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.
|
// Load the data.
|
||||||
// TODO Replace with TDB2.
|
// TODO Replace with TDB2.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
|
|
|
@ -28,12 +28,13 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More tests => 11;
|
use Test::More tests => 12;
|
||||||
|
|
||||||
# Create the rc file.
|
# Create the rc file.
|
||||||
if (open my $fh, '>', 'subst.rc')
|
if (open my $fh, '>', 'subst.rc')
|
||||||
{
|
{
|
||||||
print $fh "data.location=.\n";
|
print $fh "data.location=.\n",
|
||||||
|
"regex=off\n";
|
||||||
close $fh;
|
close $fh;
|
||||||
ok (-r 'subst.rc', 'Created subst.rc');
|
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};
|
$output = qx{../src/task rc:subst.rc info 1};
|
||||||
like ($output, qr/aaa ccc/, 'word deletion in description');
|
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.
|
# Cleanup.
|
||||||
unlink 'pending.data';
|
unlink 'pending.data';
|
||||||
ok (!-r 'pending.data', 'Removed pending.data');
|
ok (!-r 'pending.data', 'Removed pending.data');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue