]> granicus.if.org Git - icinga2/commitdiff
Improve auto-completion suggestions for the repository command
authorGunnar Beutner <gunnar@beutner.name>
Fri, 17 Oct 2014 14:02:25 +0000 (16:02 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Fri, 17 Oct 2014 14:04:11 +0000 (16:04 +0200)
refs #7255

lib/base/clicommand.cpp
lib/cli/repositoryobjectcommand.cpp

index a2aed63f2ff203fa97b5995c14dfd9198143a553..0a5062d9b1a85bb2abcb4f9e4283465c105fbf2c 100644 (file)
@@ -81,7 +81,7 @@ std::vector<String> icinga::GetFieldCompletionSuggestions(const Type *type, cons
 
                String fname = field.Name;
 
-               if (fname == "__name" || fname == "templates")
+               if (fname == "__name" || fname == "templates" || fname == "type")
                        continue;
 
                String suggestion = fname + "=";
index 7b19d0fd80fabc570f076e3b7c86ccf523f19c53..074ba82e7686de3d4e820b30ef65720ab684743d 100644 (file)
@@ -111,9 +111,12 @@ void RepositoryObjectCommand::InitParameters(boost::program_options::options_des
 
 std::vector<String> RepositoryObjectCommand::GetPositionalSuggestions(const String& word) const
 {
-       const Type *ptype = Type::GetByName(m_Type);
-       ASSERT(ptype);
-       return GetFieldCompletionSuggestions(ptype, word);
+       if (m_Command == RepositoryCommandAdd) {
+               const Type *ptype = Type::GetByName(m_Type);
+               ASSERT(ptype);
+               return GetFieldCompletionSuggestions(ptype, word);
+       } else
+               return CLICommand::GetPositionalSuggestions(word);
 }
 
 /**