From 039f49c2e6fec33d402b0560371795dbf836dea9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 8 Apr 2016 07:49:10 -0400 Subject: [PATCH] CmdTrack: Filter now created from CLI in helper --- src/commands/CmdTrack.cpp | 40 +++++---------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/src/commands/CmdTrack.cpp b/src/commands/CmdTrack.cpp index 42f7b15f..dff10720 100644 --- a/src/commands/CmdTrack.cpp +++ b/src/commands/CmdTrack.cpp @@ -35,44 +35,14 @@ int CmdTrack ( Rules& rules, Database& database) { - // TODO Parse interval. - // TODO Parse tags. - std::string start {""}; - std::string end {""}; - std::vector tags; - for (auto& arg : cli._args) - { - if (arg.hasTag ("BINARY") || - arg.hasTag ("CMD")) - continue; - - if (arg.hasTag ("HINT")) - { - expandIntervalHint (arg.attribute ("canonical"), start, end); - } - else if (arg._lextype == Lexer::Type::date) - { - if (start == "") - start = arg.attribute ("raw"); - else if (end == "") - end = arg.attribute ("raw"); - - // TODO Is this workable? Using excess date fields as tags. Might just - // be a coincidence. - else - tags.push_back (arg.attribute ("raw")); - } - else - { - tags.push_back (arg.attribute ("raw")); - } - } + // Set up a filter based on the command line. + auto filter = initializeFilterFromCLI (cli); // TODO Add new interval. Interval tracked; - tracked.start (Datetime (start)); - tracked.end (Datetime (end)); - for (auto& tag : tags) + tracked.start (filter.start ()); + tracked.end (filter.end ()); + for (auto& tag : filter.tags ()) tracked.tag (tag); // TODO Apply exclusions.