[icinga-checkins] icinga.org: icinga2/feature/apply-test: Add an option that hides CLI commands

git at icinga.org git at icinga.org
Thu Nov 20 13:56:39 CET 2014


Module: icinga2
Branch: feature/apply-test
Commit: d532300cba7dff53f129d55c0c36c9a46454627e
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=d532300cba7dff53f129d55c0c36c9a46454627e

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Mon Nov 17 18:42:22 2014 +0100

Add an option that hides CLI commands

fixes #7702

---

 lib/cli/clicommand.cpp |    7 ++++++-
 lib/cli/clicommand.hpp |    1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/cli/clicommand.cpp b/lib/cli/clicommand.cpp
index 31deb99..76ac232 100644
--- a/lib/cli/clicommand.cpp
+++ b/lib/cli/clicommand.cpp
@@ -101,6 +101,11 @@ int CLICommand::GetMaxArguments(void) const
 	return GetMinArguments();
 }
 
+bool CLICommand::IsHidden(void) const
+{
+	return false;
+}
+
 boost::mutex& CLICommand::GetRegistryMutex(void)
 {
 	static boost::mutex mtx;
@@ -271,7 +276,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
 	BOOST_FOREACH(const CLIKeyValue& kv, GetRegistry()) {
 		const std::vector<String>& vname = kv.first;
 
-		if (vname.size() < best_match.size())
+		if (vname.size() < best_match.size() || kv.second->IsHidden())
 			continue;
 
 		bool match = true;
diff --git a/lib/cli/clicommand.hpp b/lib/cli/clicommand.hpp
index a00cee8..b433e6d 100644
--- a/lib/cli/clicommand.hpp
+++ b/lib/cli/clicommand.hpp
@@ -58,6 +58,7 @@ public:
 	virtual String GetShortDescription(void) const = 0;
 	virtual int GetMinArguments(void) const;
 	virtual int GetMaxArguments(void) const;
+	virtual bool IsHidden(void) const;
 	virtual void InitParameters(boost::program_options::options_description& visibleDesc,
 	    boost::program_options::options_description& hiddenDesc) const;
 	virtual ImpersonationLevel GetImpersonationLevel(void) const;



More information about the icinga-checkins mailing list