CmdContext: Add support for unsetting context

This commit is contained in:
Tomas Babej 2015-02-21 18:28:49 +01:00 committed by Paul Beckingham
parent 371ca27da0
commit 1a3550541b
2 changed files with 21 additions and 0 deletions

View file

@ -64,6 +64,8 @@ int CmdContext::execute (std::string& output)
rc = deleteContext(words, out);
else if (subcommand == "list")
rc = listContexts(words, out);
else if (subcommand == "none")
rc = unsetContext(words, out);
else
rc = setContext(words, out);
}
@ -229,6 +231,24 @@ int CmdContext::setContext (std::vector <std::string>& words, std::stringstream&
return 0;
}
////////////////////////////////////////////////////////////////////////////////
int CmdContext::unsetContext (std::vector <std::string>& words, std::stringstream& out)
{
// task context none
int rc = 0;
int status = CmdConfig::unsetConfigVariable("context", false);
if (status == 0)
out << "Context unset." << "\n";
else
{
out << "Context not unset." << "\n";
rc = 1;
}
return rc;
}
////////////////////////////////////////////////////////////////////////////////
CmdCompletionContext::CmdCompletionContext ()
{

View file

@ -41,6 +41,7 @@ public:
int deleteContext (std::vector <std::string>& words, std::stringstream& out);
int listContexts (std::vector <std::string>& words, std::stringstream& out);
int setContext (std::vector <std::string>& words, std::stringstream& out);
int unsetContext (std::vector <std::string>& words, std::stringstream& out);
};
class CmdCompletionContext : public Command