mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CLI: Added ::identifyFilter
This commit is contained in:
parent
0b1b370054
commit
9ea8f9dd8d
2 changed files with 41 additions and 0 deletions
40
src/CLI.cpp
40
src/CLI.cpp
|
@ -109,6 +109,7 @@ std::string A2::dump () const
|
||||||
else if (tag == "CMD") tags += "\033[1;37;46m" + tag + "\033[0m ";
|
else if (tag == "CMD") tags += "\033[1;37;46m" + tag + "\033[0m ";
|
||||||
else if (tag == "EXT") tags += "\033[1;37;42m" + tag + "\033[0m ";
|
else if (tag == "EXT") tags += "\033[1;37;42m" + tag + "\033[0m ";
|
||||||
else if (tag == "HINT") tags += "\033[1;37;43m" + tag + "\033[0m ";
|
else if (tag == "HINT") tags += "\033[1;37;43m" + tag + "\033[0m ";
|
||||||
|
else if (tag == "FILTER") tags += "\033[1;37;45m" + tag + "\033[0m ";
|
||||||
else tags += "\033[32m" + tag + "\033[0m ";
|
else tags += "\033[32m" + tag + "\033[0m ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,6 +228,7 @@ void CLI::analyze ()
|
||||||
handleArg0 ();
|
handleArg0 ();
|
||||||
lexArguments ();
|
lexArguments ();
|
||||||
canonicalizeNames ();
|
canonicalizeNames ();
|
||||||
|
identifyFilter ();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -369,6 +371,44 @@ void CLI::canonicalizeNames ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Locate arguments that are part of a filter.
|
||||||
|
void CLI::identifyFilter ()
|
||||||
|
{
|
||||||
|
for (auto& a : _args)
|
||||||
|
{
|
||||||
|
auto raw = a.attribute ("raw");
|
||||||
|
|
||||||
|
if (a.hasTag ("HINT"))
|
||||||
|
a.tag ("FILTER");
|
||||||
|
|
||||||
|
else if (a._lextype == Lexer::Type::date ||
|
||||||
|
a._lextype == Lexer::Type::duration)
|
||||||
|
{
|
||||||
|
a.tag ("FILTER");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (raw == "from" ||
|
||||||
|
raw == "since" ||
|
||||||
|
raw == "to" ||
|
||||||
|
raw == "until" ||
|
||||||
|
raw == "-" ||
|
||||||
|
raw == "for")
|
||||||
|
{
|
||||||
|
a.tag ("FILTER");
|
||||||
|
a.tag ("KEYWORD");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (! a.hasTag ("CMD") &&
|
||||||
|
! a.hasTag ("EXT") &&
|
||||||
|
! a.hasTag ("BINARY"))
|
||||||
|
{
|
||||||
|
a.tag ("FILTER");
|
||||||
|
a.tag ("TAG");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Search for exact 'value' in _entities category.
|
// Search for exact 'value' in _entities category.
|
||||||
bool CLI::exactMatch (
|
bool CLI::exactMatch (
|
||||||
|
|
|
@ -69,6 +69,7 @@ private:
|
||||||
void handleArg0 ();
|
void handleArg0 ();
|
||||||
void lexArguments ();
|
void lexArguments ();
|
||||||
void canonicalizeNames ();
|
void canonicalizeNames ();
|
||||||
|
void identifyFilter ();
|
||||||
bool exactMatch (const std::string&, const std::string&) const;
|
bool exactMatch (const std::string&, const std::string&) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue