mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 04:13:07 +02:00
CmdContext: Discard .read/.write suffix when discovering contexts
This commit is contained in:
parent
41823c7939
commit
c0ded37f91
1 changed files with 11 additions and 3 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <Filter.h>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
#include <util.h>
|
||||
|
@ -109,13 +110,20 @@ std::string CmdContext::joinWords (const std::vector <std::string>& words, unsig
|
|||
//
|
||||
std::vector <std::string> CmdContext::getContexts ()
|
||||
{
|
||||
std::vector <std::string> contexts;
|
||||
std::set <std::string> contexts;
|
||||
|
||||
for (auto& name : Context::getContext ().config)
|
||||
if (name.first.substr (0, 8) == "context.")
|
||||
contexts.push_back (name.first.substr (8));
|
||||
{
|
||||
std::string suffix = name.first.substr (8);
|
||||
|
||||
return contexts;
|
||||
if (suffix.find (".") != std::string::npos)
|
||||
contexts.insert (suffix.substr (0, suffix.find (".")));
|
||||
else
|
||||
contexts.insert (suffix);
|
||||
}
|
||||
|
||||
return std::vector (contexts.begin (), contexts.end ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue