mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CmdContext: Remove old-style context during re-definition
This makes it easier to migrate from old-style context.<name>=value context definition to new context.<name>.read=value and context.<name>.write=value variables.
This commit is contained in:
parent
c28aa2f7e2
commit
c69cbe8bfc
1 changed files with 8 additions and 1 deletions
|
@ -172,7 +172,8 @@ std::vector <std::string> CmdContext::getContexts ()
|
|||
//
|
||||
void CmdContext::defineContext (const std::vector <std::string>& words, std::stringstream& out)
|
||||
{
|
||||
auto confirmation = Context::getContext ().config.getBoolean ("confirmation");
|
||||
auto config = Context::getContext ().config;
|
||||
bool confirmation = config.getBoolean ("confirmation");
|
||||
|
||||
if (words.size () > 2)
|
||||
{
|
||||
|
@ -230,6 +231,12 @@ void CmdContext::defineContext (const std::vector <std::string>& words, std::str
|
|||
if (valid_write_context)
|
||||
write_success = CmdConfig::setConfigVariable (name + ".write", value, confirmation);
|
||||
|
||||
// Remove old-school context name, if it exists, assuming the read context was defined
|
||||
if (read_success)
|
||||
if (config.has (name)) {
|
||||
CmdConfig::unsetConfigVariable (name, false);
|
||||
}
|
||||
|
||||
if (!read_success and !write_success)
|
||||
throw format ("Context '{1}' not defined.", words[1]);
|
||||
else if (!read_success)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue