CmdContext: Add show subcommand
This commit is contained in:
committed by
Paul Beckingham
parent
1a3550541b
commit
09fe5be086
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user