mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-30 11:27:19 +02:00
CLI
- Made ::canonicalize public.
This commit is contained in:
parent
4cb9330567
commit
efb84b20bf
2 changed files with 38 additions and 38 deletions
74
src/CLI.cpp
74
src/CLI.cpp
|
@ -403,6 +403,43 @@ const std::vector <std::string> CLI::getModifications ()
|
||||||
return modifications;
|
return modifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Search for 'value' in _entities category, return canonicalized value.
|
||||||
|
bool CLI::canonicalize (
|
||||||
|
std::string& canonicalized,
|
||||||
|
const std::string& category,
|
||||||
|
const std::string& value) const
|
||||||
|
{
|
||||||
|
// Find the category.
|
||||||
|
std::pair <std::multimap <std::string, std::string>::const_iterator, std::multimap <std::string, std::string>::const_iterator> c;
|
||||||
|
c = _entities.equal_range (category);
|
||||||
|
|
||||||
|
// Extract a list of entities for category.
|
||||||
|
std::vector <std::string> options;
|
||||||
|
std::multimap <std::string, std::string>::const_iterator e;
|
||||||
|
for (e = c.first; e != c.second; ++e)
|
||||||
|
{
|
||||||
|
// Shortcut: if an exact match is found, success.
|
||||||
|
if (value == e->second)
|
||||||
|
{
|
||||||
|
canonicalized = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
options.push_back (e->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Match against the options, throw away results.
|
||||||
|
std::vector <std::string> matches;
|
||||||
|
if (autoComplete (value, options, matches, minimumMatchLength) == 1)
|
||||||
|
{
|
||||||
|
canonicalized = matches[0];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
const std::string CLI::dump () const
|
const std::string CLI::dump () const
|
||||||
{
|
{
|
||||||
|
@ -596,43 +633,6 @@ bool CLI::exactMatch (
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Search for 'value' in _entities category, return canonicalized value.
|
|
||||||
bool CLI::canonicalize (
|
|
||||||
std::string& canonicalized,
|
|
||||||
const std::string& category,
|
|
||||||
const std::string& value) const
|
|
||||||
{
|
|
||||||
// Find the category.
|
|
||||||
std::pair <std::multimap <std::string, std::string>::const_iterator, std::multimap <std::string, std::string>::const_iterator> c;
|
|
||||||
c = _entities.equal_range (category);
|
|
||||||
|
|
||||||
// Extract a list of entities for category.
|
|
||||||
std::vector <std::string> options;
|
|
||||||
std::multimap <std::string, std::string>::const_iterator e;
|
|
||||||
for (e = c.first; e != c.second; ++e)
|
|
||||||
{
|
|
||||||
// Shortcut: if an exact match is found, success.
|
|
||||||
if (value == e->second)
|
|
||||||
{
|
|
||||||
canonicalized = value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
options.push_back (e->second);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Match against the options, throw away results.
|
|
||||||
std::vector <std::string> matches;
|
|
||||||
if (autoComplete (value, options, matches, minimumMatchLength) == 1)
|
|
||||||
{
|
|
||||||
canonicalized = matches[0];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// +tag --> tags _hastag_ tag
|
// +tag --> tags _hastag_ tag
|
||||||
// -tag --> tags _notag_ tag
|
// -tag --> tags _notag_ tag
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
const std::string getFilter ();
|
const std::string getFilter ();
|
||||||
const std::vector <std::string> getWords ();
|
const std::vector <std::string> getWords ();
|
||||||
const std::vector <std::string> getModifications ();
|
const std::vector <std::string> getModifications ();
|
||||||
|
bool canonicalize (std::string&, const std::string&, const std::string&) const;
|
||||||
const std::string dump () const;
|
const std::string dump () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -80,7 +81,6 @@ private:
|
||||||
void findOverrides ();
|
void findOverrides ();
|
||||||
void categorize ();
|
void categorize ();
|
||||||
bool exactMatch (const std::string&, const std::string&) const;
|
bool exactMatch (const std::string&, const std::string&) const;
|
||||||
bool canonicalize (std::string&, const std::string&, const std::string&) const;
|
|
||||||
void desugarTags ();
|
void desugarTags ();
|
||||||
void desugarAttributes ();
|
void desugarAttributes ();
|
||||||
void desugarAttributeModifiers ();
|
void desugarAttributeModifiers ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue