Context: Do not apply context for the export command

This commit is contained in:
Tomas Babej 2015-03-10 05:50:25 +01:00 committed by Paul Beckingham
parent 4eb70e68b7
commit 1465bcb918
5 changed files with 13 additions and 10 deletions

View file

@ -532,10 +532,13 @@ void CLI::applyOverrides ()
////////////////////////////////////////////////////////////////////////////////
// Extract all the FILTER-tagged items.
const std::string CLI::getFilter ()
const std::string CLI::getFilter (bool applyContext /* = true */)
{
// Handle context setting
addContextFilter ();
// Commands that don't want to respect current context should leverage
// the applyContext argument
if (applyContext)
addContextFilter ();
std::string filter = "";
if (_args.size ())

View file

@ -81,7 +81,7 @@ public:
void addRawFilter (const std::string& arg);
void analyze (bool parse = true, bool strict = false);
void applyOverrides ();
const std::string getFilter ();
const std::string getFilter (bool applyContext = true);
const std::vector <std::string> getWords ();
bool canonicalize (std::string&, const std::string&, const std::string&) const;
std::string getBinary () const;

View file

@ -67,7 +67,7 @@ Filter::~Filter ()
////////////////////////////////////////////////////////////////////////////////
// Take an input set of tasks and filter into a subset.
void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output)
void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output, bool applyContext /* = true */)
{
context.timer_filter.start ();
_startCount = (int) input.size ();
@ -75,7 +75,7 @@ void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output
if (context.config.getInteger ("debug.parser") >= 1)
context.debug (context.cli.dump ("Filter::subset"));
std::string filterExpr = context.cli.getFilter ();
std::string filterExpr = context.cli.getFilter (applyContext);
if (filterExpr.length ())
{
Eval eval;
@ -111,7 +111,7 @@ void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output
////////////////////////////////////////////////////////////////////////////////
// Take the set of all tasks and filter into a subset.
void Filter::subset (std::vector <Task>& output)
void Filter::subset (std::vector <Task>& output, bool applyContext /* = true */)
{
context.timer_filter.start ();
@ -119,7 +119,7 @@ void Filter::subset (std::vector <Task>& output)
context.debug (context.cli.dump ("Filter::subset"));
bool shortcut = false;
std::string filterExpr = context.cli.getFilter ();
std::string filterExpr = context.cli.getFilter (applyContext);
if (filterExpr.length ())
{
context.timer_filter.stop ();

View file

@ -40,8 +40,8 @@ public:
Filter ();
~Filter ();
void subset (const std::vector <Task>&, std::vector <Task>&);
void subset (std::vector <Task>&);
void subset (const std::vector <Task>&, std::vector <Task>&, bool applyContext = true);
void subset (std::vector <Task>&, bool applyContext = true);
bool pendingOnly ();
void safety ();

View file

@ -54,7 +54,7 @@ int CmdExport::execute (std::string& output)
// Apply filter.
Filter filter;
std::vector <Task> filtered;
filter.subset (filtered);
filter.subset (filtered, false);
// Obey 'limit:N'.
int rows = 0;