Debug: rc.sugar enables ID/UUID snytactic sugar

- This is not documented.  It is not for users.
This commit is contained in:
Paul Beckingham 2015-08-07 11:35:27 -04:00
parent 92d37e5124
commit 6f294e2968
4 changed files with 147 additions and 85 deletions

View file

@ -1314,6 +1314,10 @@ void CLI2::desugarFilterPatterns ()
//
void CLI2::findIDs ()
{
bool changes = false;
if (context.config.getBoolean ("sugar"))
{
bool previousFilterArgWasAnOperator = false;
int filterCount = 0;
@ -1328,6 +1332,7 @@ void CLI2::findIDs ()
// Skip any number that was preceded by an operator.
if (! previousFilterArgWasAnOperator)
{
changes = true;
std::string number = a.attribute ("raw");
_id_ranges.push_back (std::pair <std::string, std::string> (number, number));
}
@ -1340,6 +1345,7 @@ void CLI2::findIDs ()
for (auto& element : elements)
{
changes = true;
auto hyphen = element.find ("-");
if (hyphen != std::string::npos)
{
@ -1383,6 +1389,7 @@ void CLI2::findIDs ()
raw.find ('e') == std::string::npos &&
raw.find ('-') == std::string::npos)
{
changes = true;
a.unTag ("MODIFICATION");
a.tag ("FILTER");
_id_ranges.push_back (std::pair <std::string, std::string> (raw, raw));
@ -1398,6 +1405,7 @@ void CLI2::findIDs ()
for (auto& element : elements)
{
changes = true;
auto hyphen = element.find ("-");
if (hyphen != std::string::npos)
{
@ -1412,8 +1420,32 @@ void CLI2::findIDs ()
}
}
}
}
if (_id_ranges.size ())
// Sugar-free.
else
{
std::vector <A2> reconstructed;
for (auto& a : _args)
{
if (a.hasTag ("FILTER") &&
a._lextype == Lexer::Type::number)
{
changes = true;
A2 pair ("id:" + a.attribute ("raw"), Lexer::Type::pair);
pair.tag ("FILTER");
pair.decompose ();
reconstructed.push_back (pair);
}
else
reconstructed.push_back (a);
}
if (changes)
_args = reconstructed;
}
if (changes)
if (context.config.getInteger ("debug.parser") >= 3)
context.debug (dump ("CLI2::prepareFilter findIDs"));
}
@ -1421,11 +1453,16 @@ void CLI2::findIDs ()
////////////////////////////////////////////////////////////////////////////////
void CLI2::findUUIDs ()
{
bool changes = false;
if (context.config.getBoolean ("sugar"))
{
for (auto& a : _args)
{
if (a._lextype == Lexer::Type::uuid &&
a.hasTag ("FILTER"))
{
changes = true;
_uuid_list.push_back (a.attribute ("raw"));
}
}
@ -1437,14 +1474,39 @@ void CLI2::findUUIDs ()
if (a._lextype == Lexer::Type::uuid &&
a.hasTag ("MODIFICATION"))
{
changes = true;
a.unTag ("MODIFICATION");
a.tag ("FILTER");
_uuid_list.push_back (a.attribute ("raw"));
}
}
}
}
if (_uuid_list.size ())
// Sugar-free.
else
{
std::vector <A2> reconstructed;
for (auto& a : _args)
{
if (a.hasTag ("FILTER") &&
a._lextype == Lexer::Type::uuid)
{
changes = true;
A2 pair ("uuid:" + a.attribute ("raw"), Lexer::Type::pair);
pair.tag ("FILTER");
pair.decompose ();
reconstructed.push_back (pair);
}
else
reconstructed.push_back (a);
}
if (changes)
_args = reconstructed;
}
if (changes)
if (context.config.getInteger ("debug.parser") >= 3)
context.debug (dump ("CLI2::prepareFilter findUUIDs"));
}

View file

@ -47,8 +47,6 @@ public:
const std::string attribute (const std::string&) const;
const std::string getToken () const;
const std::string dump () const;
private:
void decompose ();
public:

View file

@ -342,6 +342,7 @@ std::string Config::_defaults =
"list.all.tags=no # Include old tag names in 'tags' command\n"
"print.empty.columns=no # Print columns which have no data for any task\n"
"debug=no # Display diagnostics\n"
"sugar=yes # Syntactic sugar\n"
"obfuscate=no # Obfuscate data for error reporting\n"
"fontunderline=yes # Uses underlines rather than -------\n"
"shell.prompt=task> # Prompt used by the shell command\n"

View file

@ -186,6 +186,7 @@ int CmdShow::execute (std::string& output)
" rule.precedence.color"
" search.case.sensitive"
" shell.prompt"
" sugar"
" summary.all.projects"
" tag.indicator"
" taskd.server"