mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI
- Corrected lookup for existing entities.
This commit is contained in:
parent
7420ef8e28
commit
9bc8e3bae3
1 changed files with 12 additions and 2 deletions
14
src/CLI.cpp
14
src/CLI.cpp
|
@ -243,8 +243,18 @@ void CLI::alias (const std::string& name, const std::string& value)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CLI::entity (const std::string& category, const std::string& name)
|
void CLI::entity (const std::string& category, const std::string& name)
|
||||||
{
|
{
|
||||||
if (_entities.find (category) == _entities.end ())
|
// Find the category.
|
||||||
_entities.insert (std::pair <std::string, std::string> (category, name));
|
std::pair <std::multimap <std::string, std::string>::const_iterator, std::multimap <std::string, std::string>::const_iterator> c;
|
||||||
|
c = _entities.equal_range (category);
|
||||||
|
|
||||||
|
// Walk the list of entities for category.
|
||||||
|
std::multimap <std::string, std::string>::const_iterator e;
|
||||||
|
for (e = c.first; e != c.second; ++e)
|
||||||
|
if (e->second == name)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// The category/name pair was not found, therefore add it.
|
||||||
|
_entities.insert (std::pair <std::string, std::string> (category, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue