From d16670c4b7959fdda22a6487931f9fa580093bda Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 17 Oct 2014 16:02:25 +0200 Subject: [PATCH] Improve auto-completion suggestions for the repository command refs #7255 --- lib/base/clicommand.cpp | 2 +- lib/cli/repositoryobjectcommand.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/base/clicommand.cpp b/lib/base/clicommand.cpp index a2aed63f2..0a5062d9b 100644 --- a/lib/base/clicommand.cpp +++ b/lib/base/clicommand.cpp @@ -81,7 +81,7 @@ std::vector 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 + "="; diff --git a/lib/cli/repositoryobjectcommand.cpp b/lib/cli/repositoryobjectcommand.cpp index 7b19d0fd8..074ba82e7 100644 --- a/lib/cli/repositoryobjectcommand.cpp +++ b/lib/cli/repositoryobjectcommand.cpp @@ -111,9 +111,12 @@ void RepositoryObjectCommand::InitParameters(boost::program_options::options_des std::vector 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); } /** -- 2.40.0