mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 19:17:19 +02:00
Debug: rc.sugar enables ID/UUID snytactic sugar
- This is not documented. It is not for users.
This commit is contained in:
parent
92d37e5124
commit
6f294e2968
4 changed files with 147 additions and 85 deletions
66
src/CLI2.cpp
66
src/CLI2.cpp
|
|
@ -1314,6 +1314,10 @@ void CLI2::desugarFilterPatterns ()
|
||||||
//
|
//
|
||||||
void CLI2::findIDs ()
|
void CLI2::findIDs ()
|
||||||
{
|
{
|
||||||
|
bool changes = false;
|
||||||
|
|
||||||
|
if (context.config.getBoolean ("sugar"))
|
||||||
|
{
|
||||||
bool previousFilterArgWasAnOperator = false;
|
bool previousFilterArgWasAnOperator = false;
|
||||||
int filterCount = 0;
|
int filterCount = 0;
|
||||||
|
|
||||||
|
|
@ -1328,6 +1332,7 @@ void CLI2::findIDs ()
|
||||||
// Skip any number that was preceded by an operator.
|
// Skip any number that was preceded by an operator.
|
||||||
if (! previousFilterArgWasAnOperator)
|
if (! previousFilterArgWasAnOperator)
|
||||||
{
|
{
|
||||||
|
changes = true;
|
||||||
std::string number = a.attribute ("raw");
|
std::string number = a.attribute ("raw");
|
||||||
_id_ranges.push_back (std::pair <std::string, std::string> (number, number));
|
_id_ranges.push_back (std::pair <std::string, std::string> (number, number));
|
||||||
}
|
}
|
||||||
|
|
@ -1340,6 +1345,7 @@ void CLI2::findIDs ()
|
||||||
|
|
||||||
for (auto& element : elements)
|
for (auto& element : elements)
|
||||||
{
|
{
|
||||||
|
changes = true;
|
||||||
auto hyphen = element.find ("-");
|
auto hyphen = element.find ("-");
|
||||||
if (hyphen != std::string::npos)
|
if (hyphen != std::string::npos)
|
||||||
{
|
{
|
||||||
|
|
@ -1383,6 +1389,7 @@ void CLI2::findIDs ()
|
||||||
raw.find ('e') == std::string::npos &&
|
raw.find ('e') == std::string::npos &&
|
||||||
raw.find ('-') == std::string::npos)
|
raw.find ('-') == std::string::npos)
|
||||||
{
|
{
|
||||||
|
changes = true;
|
||||||
a.unTag ("MODIFICATION");
|
a.unTag ("MODIFICATION");
|
||||||
a.tag ("FILTER");
|
a.tag ("FILTER");
|
||||||
_id_ranges.push_back (std::pair <std::string, std::string> (raw, raw));
|
_id_ranges.push_back (std::pair <std::string, std::string> (raw, raw));
|
||||||
|
|
@ -1398,6 +1405,7 @@ void CLI2::findIDs ()
|
||||||
|
|
||||||
for (auto& element : elements)
|
for (auto& element : elements)
|
||||||
{
|
{
|
||||||
|
changes = true;
|
||||||
auto hyphen = element.find ("-");
|
auto hyphen = element.find ("-");
|
||||||
if (hyphen != std::string::npos)
|
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)
|
if (context.config.getInteger ("debug.parser") >= 3)
|
||||||
context.debug (dump ("CLI2::prepareFilter findIDs"));
|
context.debug (dump ("CLI2::prepareFilter findIDs"));
|
||||||
}
|
}
|
||||||
|
|
@ -1421,11 +1453,16 @@ void CLI2::findIDs ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CLI2::findUUIDs ()
|
void CLI2::findUUIDs ()
|
||||||
{
|
{
|
||||||
|
bool changes = false;
|
||||||
|
|
||||||
|
if (context.config.getBoolean ("sugar"))
|
||||||
|
{
|
||||||
for (auto& a : _args)
|
for (auto& a : _args)
|
||||||
{
|
{
|
||||||
if (a._lextype == Lexer::Type::uuid &&
|
if (a._lextype == Lexer::Type::uuid &&
|
||||||
a.hasTag ("FILTER"))
|
a.hasTag ("FILTER"))
|
||||||
{
|
{
|
||||||
|
changes = true;
|
||||||
_uuid_list.push_back (a.attribute ("raw"));
|
_uuid_list.push_back (a.attribute ("raw"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1437,14 +1474,39 @@ void CLI2::findUUIDs ()
|
||||||
if (a._lextype == Lexer::Type::uuid &&
|
if (a._lextype == Lexer::Type::uuid &&
|
||||||
a.hasTag ("MODIFICATION"))
|
a.hasTag ("MODIFICATION"))
|
||||||
{
|
{
|
||||||
|
changes = true;
|
||||||
a.unTag ("MODIFICATION");
|
a.unTag ("MODIFICATION");
|
||||||
a.tag ("FILTER");
|
a.tag ("FILTER");
|
||||||
_uuid_list.push_back (a.attribute ("raw"));
|
_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)
|
if (context.config.getInteger ("debug.parser") >= 3)
|
||||||
context.debug (dump ("CLI2::prepareFilter findUUIDs"));
|
context.debug (dump ("CLI2::prepareFilter findUUIDs"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,6 @@ public:
|
||||||
const std::string attribute (const std::string&) const;
|
const std::string attribute (const std::string&) const;
|
||||||
const std::string getToken () const;
|
const std::string getToken () const;
|
||||||
const std::string dump () const;
|
const std::string dump () const;
|
||||||
|
|
||||||
private:
|
|
||||||
void decompose ();
|
void decompose ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -342,6 +342,7 @@ std::string Config::_defaults =
|
||||||
"list.all.tags=no # Include old tag names in 'tags' command\n"
|
"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"
|
"print.empty.columns=no # Print columns which have no data for any task\n"
|
||||||
"debug=no # Display diagnostics\n"
|
"debug=no # Display diagnostics\n"
|
||||||
|
"sugar=yes # Syntactic sugar\n"
|
||||||
"obfuscate=no # Obfuscate data for error reporting\n"
|
"obfuscate=no # Obfuscate data for error reporting\n"
|
||||||
"fontunderline=yes # Uses underlines rather than -------\n"
|
"fontunderline=yes # Uses underlines rather than -------\n"
|
||||||
"shell.prompt=task> # Prompt used by the shell command\n"
|
"shell.prompt=task> # Prompt used by the shell command\n"
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,7 @@ int CmdShow::execute (std::string& output)
|
||||||
" rule.precedence.color"
|
" rule.precedence.color"
|
||||||
" search.case.sensitive"
|
" search.case.sensitive"
|
||||||
" shell.prompt"
|
" shell.prompt"
|
||||||
|
" sugar"
|
||||||
" summary.all.projects"
|
" summary.all.projects"
|
||||||
" tag.indicator"
|
" tag.indicator"
|
||||||
" taskd.server"
|
" taskd.server"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue