mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
CLI
- Converted from std::string to A.
This commit is contained in:
parent
854dc08615
commit
6388d3827b
2 changed files with 37 additions and 25 deletions
56
src/CLI.cpp
56
src/CLI.cpp
|
@ -129,10 +129,10 @@ void A::attribute (const std::string& name, const double value)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Accessor for attributes.
|
// Accessor for attributes.
|
||||||
const std::string A::attribute (const std::string& name)
|
const std::string A::attribute (const std::string& name) const
|
||||||
{
|
{
|
||||||
// Prevent autovivification.
|
// Prevent autovivification.
|
||||||
std::map<std::string, std::string>::iterator i = _attributes.find (name);
|
std::map<std::string, std::string>::const_iterator i = _attributes.find (name);
|
||||||
if (i != _attributes.end ())
|
if (i != _attributes.end ())
|
||||||
return i->second;
|
return i->second;
|
||||||
|
|
||||||
|
@ -289,13 +289,13 @@ const std::string CLI::getFilter ()
|
||||||
{
|
{
|
||||||
filter = "(";
|
filter = "(";
|
||||||
|
|
||||||
std::vector <std::string>::const_iterator i;
|
std::vector <A>::const_iterator i;
|
||||||
for (i = _filter.begin (); i != _filter.end (); ++i)
|
for (i = _filter.begin (); i != _filter.end (); ++i)
|
||||||
{
|
{
|
||||||
if (i != _filter.begin ())
|
if (i != _filter.begin ())
|
||||||
filter += ' ';
|
filter += ' ';
|
||||||
|
|
||||||
filter += *i;
|
filter += i->attribute ("raw");
|
||||||
}
|
}
|
||||||
|
|
||||||
filter += ')';
|
filter += ')';
|
||||||
|
@ -402,11 +402,15 @@ void CLI::categorize ()
|
||||||
}
|
}
|
||||||
else if (foundCommand && ! _readOnly)
|
else if (foundCommand && ! _readOnly)
|
||||||
{
|
{
|
||||||
_modifications.push_back (raw);
|
A a ("argMod", raw);
|
||||||
|
a.tag ("MODIFICATION");
|
||||||
|
_modifications.push_back (a);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_filter.push_back (raw);
|
A a ("argFilt", raw);
|
||||||
|
a.tag ("FILTER");
|
||||||
|
_filter.push_back (a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,12 +480,11 @@ bool CLI::canonicalize (
|
||||||
// -tag --> tags _notag_ tag
|
// -tag --> tags _notag_ tag
|
||||||
void CLI::unsweetenTags ()
|
void CLI::unsweetenTags ()
|
||||||
{
|
{
|
||||||
std::vector <std::string> reconstructed;
|
std::vector <A> reconstructed;
|
||||||
|
std::vector <A>::iterator i;
|
||||||
std::vector <std::string>::iterator i;
|
|
||||||
for (i = _filter.begin (); i != _filter.end (); ++i)
|
for (i = _filter.begin (); i != _filter.end (); ++i)
|
||||||
{
|
{
|
||||||
Nibbler n (*i);
|
Nibbler n (i->attribute ("raw"));
|
||||||
std::string tag;
|
std::string tag;
|
||||||
std::string sign;
|
std::string sign;
|
||||||
|
|
||||||
|
@ -490,9 +493,17 @@ void CLI::unsweetenTags ()
|
||||||
n.getUntilEOS (tag) &&
|
n.getUntilEOS (tag) &&
|
||||||
tag.find (' ') == std::string::npos)
|
tag.find (' ') == std::string::npos)
|
||||||
{
|
{
|
||||||
reconstructed.push_back ("tags");
|
A left ("argTag", "tags");
|
||||||
reconstructed.push_back (sign == "+" ? "_hastag_" : "_notag_");
|
left.tag ("ATT");
|
||||||
reconstructed.push_back (tag);
|
reconstructed.push_back (left);
|
||||||
|
|
||||||
|
A op ("argTag", sign == "+" ? "_hastag_" : "_notag_");
|
||||||
|
op.tag ("OP");
|
||||||
|
reconstructed.push_back (op);
|
||||||
|
|
||||||
|
A right ("argTag", tag);
|
||||||
|
right.tag ("LITERAL");
|
||||||
|
reconstructed.push_back (right);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
reconstructed.push_back (*i);
|
reconstructed.push_back (*i);
|
||||||
|
@ -529,20 +540,21 @@ void CLI::dump (const std::string& label) const
|
||||||
for (m = _overrides.begin (); m != _overrides.end (); ++m)
|
for (m = _overrides.begin (); m != _overrides.end (); ++m)
|
||||||
std::cout << " _overrides " << m->first << " --> " << m->second << "\n";
|
std::cout << " _overrides " << m->first << " --> " << m->second << "\n";
|
||||||
|
|
||||||
std::cout << " _filter ";
|
if (_filter.size ())
|
||||||
Color colorFilter ("gray20 on gray8");
|
|
||||||
for (i = _filter.begin (); i != _filter.end (); ++i)
|
|
||||||
{
|
{
|
||||||
if (i != _filter.begin ())
|
std::cout << " _filter\n";
|
||||||
std::cout << ' ';
|
for (a = _filter.begin (); a != _filter.end (); ++a)
|
||||||
std::cout << colorFilter.colorize (*i);
|
std::cout << " " << a->dump () << "\n";
|
||||||
}
|
}
|
||||||
std::cout << "\n";
|
|
||||||
|
|
||||||
std::cout << " _command " << _command << " " << (_readOnly ? "(read)" : "(write)") << "\n";
|
std::cout << " _command " << _command << " " << (_readOnly ? "(read)" : "(write)") << "\n";
|
||||||
|
|
||||||
for (i = _modifications.begin (); i != _modifications.end (); ++i)
|
if (_modifications.size ())
|
||||||
std::cout << " _modifications " << *i << "\n";
|
{
|
||||||
|
std::cout << " _modifications\n";
|
||||||
|
for (a = _modifications.begin (); a != _modifications.end (); ++a)
|
||||||
|
std::cout << " " << a->dump () << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
void attribute (const std::string&, const std::string&);
|
void attribute (const std::string&, const std::string&);
|
||||||
void attribute (const std::string&, const int);
|
void attribute (const std::string&, const int);
|
||||||
void attribute (const std::string&, const double);
|
void attribute (const std::string&, const double);
|
||||||
const std::string attribute (const std::string&);
|
const std::string attribute (const std::string&) const;
|
||||||
void removeAttribute (const std::string&);
|
void removeAttribute (const std::string&);
|
||||||
const std::string dump () const;
|
const std::string dump () const;
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ public:
|
||||||
std::map <std::string, std::string> _overrides;
|
std::map <std::string, std::string> _overrides;
|
||||||
std::string _command;
|
std::string _command;
|
||||||
bool _readOnly;
|
bool _readOnly;
|
||||||
std::vector <std::string> _filter;
|
std::vector <A> _filter;
|
||||||
std::vector <std::string> _modifications;
|
std::vector <A> _modifications;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue