mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-10 04:00:37 +02:00
CmdContext: Define both read and write context
This commit is contained in:
parent
26fb4521fe
commit
985aab0541
1 changed files with 11 additions and 4 deletions
|
@ -165,11 +165,18 @@ void CmdContext::defineContext (const std::vector <std::string>& words, std::str
|
||||||
! confirm (format ("The filter '{1}' matches 0 pending tasks. Do you wish to continue?", value)))
|
! confirm (format ("The filter '{1}' matches 0 pending tasks. Do you wish to continue?", value)))
|
||||||
throw std::string ("Context definition aborted.");
|
throw std::string ("Context definition aborted.");
|
||||||
|
|
||||||
// Set context definition config variable
|
// TODO: Validate the context as valid for writing and prompt for alternative if invald
|
||||||
bool success = CmdConfig::setConfigVariable (name, value, confirmation);
|
|
||||||
|
|
||||||
if (!success)
|
// Set context definition config variable
|
||||||
throw format ("Context '{1}' not defined.", words[1]);
|
bool read_success = CmdConfig::setConfigVariable (name + ".read", value, confirmation);
|
||||||
|
bool write_success = CmdConfig::setConfigVariable (name + ".write", value, confirmation);
|
||||||
|
|
||||||
|
if (!read_success and !write_success)
|
||||||
|
throw format ("Context '{1}' not defined (setting read and write failed).", words[1]);
|
||||||
|
else if (!read_success)
|
||||||
|
throw format ("Context '{1}' not defined (setting read failed).", words[1]);
|
||||||
|
else if (!write_success)
|
||||||
|
throw format ("Context '{1}' not defined (setting write failed).", words[1]);
|
||||||
|
|
||||||
out << format ("Context '{1}' defined. Use 'task context {1}' to activate.\n", words[1]);
|
out << format ("Context '{1}' defined. Use 'task context {1}' to activate.\n", words[1]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue