]> granicus.if.org Git - icinga2/commitdiff
Add an option that hides CLI commands
authorGunnar Beutner <gunnar@beutner.name>
Mon, 17 Nov 2014 17:42:22 +0000 (18:42 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 17 Nov 2014 17:42:22 +0000 (18:42 +0100)
fixes #7702

lib/cli/clicommand.cpp
lib/cli/clicommand.hpp

index 31deb99586e0c444945f29f1ffc43f0b8211dad4..76ac23230450802e9254fc8a0d8fe95909bb34f7 100644 (file)
@@ -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;
index a00cee8ea1263c147c668147a6a1ec3b655858d3..b433e6ddf1e16616789eebc9d0468b4181cf4c97 100644 (file)
@@ -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;