Improve auto-completion suggestions for the repository command

refs #7255
This commit is contained in:
Gunnar Beutner 2014-10-17 16:02:25 +02:00
parent 7db8588980
commit d16670c4b7
2 changed files with 7 additions and 4 deletions

View 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 + "=";

View 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);
}
/**