CmdContext: Add show subcommand

This commit is contained in:
Tomas Babej 2015-02-21 18:50:14 +01:00 committed by Paul Beckingham
parent 1a3550541b
commit 09fe5be086
2 changed files with 20 additions and 0 deletions

View file

@ -66,6 +66,8 @@ int CmdContext::execute (std::string& output)
rc = listContexts(words, out);
else if (subcommand == "none")
rc = unsetContext(words, out);
else if (subcommand == "show")
rc = showContext(words, out);
else
rc = setContext(words, out);
}
@ -231,6 +233,23 @@ int CmdContext::setContext (std::vector <std::string>& words, std::stringstream&
return 0;
}
////////////////////////////////////////////////////////////////////////////////
int CmdContext::showContext (std::vector <std::string>& words, std::stringstream& out)
{
// task context show
std::string currentContext = context.config.get ("context");
if (currentContext == "")
out << "No context is currently applied." << "\n";
else
{
std::string currentFilter = context.config.get ("context." + currentContext);
out << format ("Context '{1}' with filter '{2}' is currently applied.", currentContext, currentFilter) << "\n";
}
return 0;
}
////////////////////////////////////////////////////////////////////////////////
int CmdContext::unsetContext (std::vector <std::string>& words, std::stringstream& out)
{

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 showContext (std::vector <std::string>& words, std::stringstream& out);
int unsetContext (std::vector <std::string>& words, std::stringstream& out);
};