mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 13:37:20 +02:00
CLI2: Added ::decomposeModSubstitutions
This commit is contained in:
parent
b4b15c7f45
commit
c1f4cc3554
2 changed files with 14 additions and 28 deletions
40
src/CLI2.cpp
40
src/CLI2.cpp
|
@ -536,9 +536,7 @@ void CLI2::prepareFilter (bool applyContext)
|
|||
decomposeModAttributeModifiers ();
|
||||
*/
|
||||
decomposeModTags ();
|
||||
/*
|
||||
decomposeModSubstitutions ();
|
||||
*/
|
||||
|
||||
if (changes &&
|
||||
context.config.getInteger ("debug.parser") >= 3)
|
||||
|
@ -1667,51 +1665,39 @@ void CLI2::decomposeModTags ()
|
|||
|
||||
if (changes &&
|
||||
context.config.getInteger ("debug.parser") >= 3)
|
||||
context.debug (dump ("CLI2::analyze decomposeModTags"));
|
||||
context.debug (dump ("CLI2::prepareFilter decomposeModTags"));
|
||||
}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CLI2::decomposeModSubstitutions ()
|
||||
{
|
||||
bool changes = false;
|
||||
for (auto& a : _args)
|
||||
{
|
||||
if (a.hasTag ("TERMINATOR"))
|
||||
break;
|
||||
|
||||
if (a.hasTag ("MODIFICATION"))
|
||||
if (a._lextype == Lexer::Type::substitution &&
|
||||
a.hasTag ("MODIFICATION"))
|
||||
{
|
||||
std::string raw = a.attribute ("raw");
|
||||
Nibbler n (raw);
|
||||
std::string from;
|
||||
std::string to;
|
||||
bool global = false;
|
||||
if (n.getQuoted ('/', from) &&
|
||||
n.backN () &&
|
||||
n.getQuoted ('/', to))
|
||||
if (! Directory (raw).exists ())
|
||||
{
|
||||
if (n.skip ('g'))
|
||||
global = true;
|
||||
auto slash1 = raw.find ("/");
|
||||
auto slash2 = raw.find ("/", slash1 + 1);
|
||||
auto slash3 = raw.find ("/", slash2 + 1);
|
||||
|
||||
if (n.depleted () &&
|
||||
! Directory (raw).exists ())
|
||||
{
|
||||
a.tag ("SUBSTITUTION");
|
||||
a.attribute ("from", from);
|
||||
a.attribute ("to", to);
|
||||
a.attribute ("global", global ? 1 : 0);
|
||||
changes = true;
|
||||
}
|
||||
a.attribute ("from", raw.substr (slash1 + 1, slash2 - slash1 - 1));
|
||||
a.attribute ("to", raw.substr (slash2 + 1, slash3 - slash2 - 1));
|
||||
a.attribute ("global", raw.substr (slash3 + 1) == "g" ? 1 : 0);
|
||||
changes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changes &&
|
||||
context.config.getInteger ("debug.parser") >= 3)
|
||||
context.debug (dump ("CLI2::analyze decomposeModSubstitutions"));
|
||||
context.debug (dump ("CLI2::prepareFilter decomposeModSubstitutions"));
|
||||
}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CLI2::isUUIDList (const std::string& raw) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue