mirror of https://github.com/Icinga/icinga2.git
parent
f13ea9e1b8
commit
8e7fd1f40d
|
@ -69,6 +69,27 @@ static std::vector<String> BashArgumentCompletionHelper(const String& type, cons
|
|||
return result;
|
||||
}
|
||||
|
||||
void icinga::AddTypeFields(const String& type, boost::program_options::options_description& desc)
|
||||
{
|
||||
const Type *ptype = Type::GetByName(type);
|
||||
|
||||
if (!ptype)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < ptype->GetFieldCount(); i++) {
|
||||
Field field = ptype->GetFieldInfo(i);
|
||||
|
||||
if (strcmp(field.Name, "__name") == 0)
|
||||
continue;
|
||||
|
||||
if (!(field.Attributes & FAConfig))
|
||||
continue;
|
||||
|
||||
desc.add_options()
|
||||
(field.Name, po::value<std::string>(), field.Name);
|
||||
}
|
||||
}
|
||||
|
||||
ArgumentCompletionCallback icinga::BashArgumentCompletion(const String& type)
|
||||
{
|
||||
return boost::bind(BashArgumentCompletionHelper, type, _1);
|
||||
|
|
|
@ -33,6 +33,7 @@ typedef boost::function<std::vector<String> (const String&)> ArgumentCompletionC
|
|||
typedef std::map<String, ArgumentCompletionCallback> ArgumentCompletionDescription;
|
||||
|
||||
I2_BASE_API ArgumentCompletionCallback BashArgumentCompletion(const String& type);
|
||||
I2_BASE_API void AddTypeFields(const String& type, boost::program_options::options_description& desc);
|
||||
|
||||
/**
|
||||
* A CLI command.
|
||||
|
|
|
@ -28,7 +28,7 @@ endif()
|
|||
|
||||
add_library(cli SHARED ${cli_SOURCES})
|
||||
|
||||
target_link_libraries(cli ${Boost_LIBRARIES} base config remote)
|
||||
target_link_libraries(cli ${Boost_LIBRARIES} base config remote icinga)
|
||||
|
||||
set_target_properties (
|
||||
cli PROPERTIES
|
||||
|
|
Loading…
Reference in New Issue