mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI2: The ::analyze framework is in place
- Now the CLI2::analyze framework is in place, the new implementation of arg analysis can be built. This algorithm first stores added arguments as-is, then processes them into lexemes, relying on Lexer::Type. Any new arguments added invalidate prior analysis.
This commit is contained in:
parent
59429e9af8
commit
7060c82767
1 changed files with 15 additions and 5 deletions
20
src/CLI2.cpp
20
src/CLI2.cpp
|
@ -343,6 +343,9 @@ void CLI2::entity (const std::string& category, const std::string& name)
|
||||||
void CLI2::add (const std::string& argument)
|
void CLI2::add (const std::string& argument)
|
||||||
{
|
{
|
||||||
_original_args.push_back (argument);
|
_original_args.push_back (argument);
|
||||||
|
|
||||||
|
// Adding a new argument invalidates prior analysis.
|
||||||
|
_args.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -357,7 +360,6 @@ void CLI2::analyze ()
|
||||||
{
|
{
|
||||||
std::string raw = _original_args[i];
|
std::string raw = _original_args[i];
|
||||||
A2 a ("arg", raw, Lexer::Type::word);
|
A2 a ("arg", raw, Lexer::Type::word);
|
||||||
/*
|
|
||||||
a.tag ("ORIGINAL");
|
a.tag ("ORIGINAL");
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
|
@ -375,22 +377,29 @@ void CLI2::analyze ()
|
||||||
else if (basename == "task" || basename == "tw" || basename == "t")
|
else if (basename == "task" || basename == "tw" || basename == "t")
|
||||||
a.tag ("TW");
|
a.tag ("TW");
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
_args.push_back (a);
|
_args.push_back (a);
|
||||||
|
|
||||||
/*
|
|
||||||
if (a.hasTag ("CALENDAR"))
|
if (a.hasTag ("CALENDAR"))
|
||||||
{
|
{
|
||||||
A cal ("argCal", "calendar");
|
A2 cal ("argCal", "calendar", Lexer::Type::word);
|
||||||
_args.push_back (cal);
|
_args.push_back (cal);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.config.getInteger ("debug.parser") >= 3)
|
||||||
|
{
|
||||||
|
context.debug ("---------------------------------------------------------------------------------");
|
||||||
|
context.debug (dump ("CLI2::analyze start"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Analysis here.
|
||||||
|
|
||||||
if (context.config.getInteger ("debug.parser") >= 3)
|
if (context.config.getInteger ("debug.parser") >= 3)
|
||||||
{
|
{
|
||||||
context.debug (dump ());
|
context.debug (dump ());
|
||||||
context.debug ("CLI2::analyze end");
|
context.debug ("CLI2::analyze end");
|
||||||
|
context.debug ("---------------------------------------------------------------------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,6 +720,7 @@ const std::string CLI2::dump (const std::string& title) const
|
||||||
|
|
||||||
out << "\033[1m" << title << "\033[0m\n"
|
out << "\033[1m" << title << "\033[0m\n"
|
||||||
<< " _original_args\n ";
|
<< " _original_args\n ";
|
||||||
|
|
||||||
Color colorOrigArgs ("gray10 on gray4");
|
Color colorOrigArgs ("gray10 on gray4");
|
||||||
for (auto i = _original_args.begin (); i != _original_args.end (); ++i)
|
for (auto i = _original_args.begin (); i != _original_args.end (); ++i)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue