static void Unregister(const std::vector<String>& name);
static bool ParseCommand(int argc, char **argv, boost::program_options::options_description& visibleDesc,
- boost::program_options::options_description& hiddenDesc,
- boost::program_options::positional_options_description& positionalDesc,
- ArgumentCompletionDescription& argCompletionDesc,
- boost::program_options::variables_map& vm, String& cmdname,
- CLICommand::Ptr& command, bool autocomplete);
+ boost::program_options::options_description& hiddenDesc,
+ boost::program_options::positional_options_description& positionalDesc,
+ ArgumentCompletionDescription& argCompletionDesc,
+ boost::program_options::variables_map& vm, String& cmdname,
+ CLICommand::Ptr& command, bool autocomplete);
static void ShowCommands(int argc, char **argv,
- boost::program_options::options_description *visibleDesc = NULL,
+ boost::program_options::options_description *visibleDesc = NULL,
boost::program_options::options_description *hiddenDesc = NULL,
ArgumentCompletionDescription *argCompletionDesc = NULL,
bool autocomplete = false, int autoindex = -1);
boost::program_options::options_description& hiddenDesc,
ArgumentCompletionDescription& argCompletionDesc) const
{
- /* Command doesn't support any parameters. */
+ /* Command doesn't support any parameters. */
}
/**
{
#ifdef _WIN32
//TODO: Add Windows support
- Log(LogInformation, "cli", "This command is not available on Windows.");
+ Log(LogInformation, "cli", "This command is not available on Windows.");
#else
- String features_enabled_dir = Application::GetSysconfDir() + "/icinga2/features-enabled";
+ String features_enabled_dir = Application::GetSysconfDir() + "/icinga2/features-enabled";
- if (ap.empty()) {
- Log(LogCritical, "cli", "Cannot disable feature(s). Name(s) are missing!");
- return 0;
- }
+ if (ap.empty()) {
+ Log(LogCritical, "cli", "Cannot disable feature(s). Name(s) are missing!");
+ return 0;
+ }
- if (!Utility::PathExists(features_enabled_dir) ) {
- Log(LogCritical, "cli", "Cannot disable features. Path '" + features_enabled_dir + "' does not exist.");
- return 0;
- }
+ if (!Utility::PathExists(features_enabled_dir) ) {
+ Log(LogCritical, "cli", "Cannot disable features. Path '" + features_enabled_dir + "' does not exist.");
+ return 0;
+ }
- std::vector<std::string> errors;
+ std::vector<std::string> errors;
- BOOST_FOREACH(const String& feature, ap) {
- String target = features_enabled_dir + "/" + feature + ".conf";
+ BOOST_FOREACH(const String& feature, ap) {
+ String target = features_enabled_dir + "/" + feature + ".conf";
- if (!Utility::PathExists(target) ) {
- Log(LogCritical, "cli", "Cannot disable feature '" + feature + "'. Target file '" + target + "' does not exist.");
- errors.push_back(feature);
- continue;
- }
+ if (!Utility::PathExists(target) ) {
+ Log(LogCritical, "cli", "Cannot disable feature '" + feature + "'. Target file '" + target + "' does not exist.");
+ errors.push_back(feature);
+ continue;
+ }
- if (unlink(target.CStr()) < 0) {
+ if (unlink(target.CStr()) < 0) {
Log(LogCritical, "cli", "Cannot disable feature '" + feature + "'. Unlinking target file '" + target +
"' failed with error code " + Convert::ToString(errno) + ", \"" + Utility::FormatErrorNumber(errno) + "\".");
- errors.push_back(feature);
- continue;
+ errors.push_back(feature);
+ continue;
}
- Log(LogInformation, "cli", "Disabling feature " + feature + " in '" + features_enabled_dir + "'.");
- }
+ Log(LogInformation, "cli", "Disabling feature " + feature + " in '" + features_enabled_dir + "'.");
+ }
- if (!errors.empty()) {
- Log(LogCritical, "cli", "Cannot disable feature(s): " + boost::algorithm::join(errors, " "));
+ if (!errors.empty()) {
+ Log(LogCritical, "cli", "Cannot disable feature(s): " + boost::algorithm::join(errors, " "));
errors.clear();
- return 1;
- }
+ return 1;
+ }
#endif /* _WIN32 */
boost::program_options::options_description& hiddenDesc,
ArgumentCompletionDescription& argCompletionDesc) const
{
- /* Command doesn't support any parameters. */
+ /* Command doesn't support any parameters. */
}
/**
*/
int FeatureListCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
{
- if (!ap.empty()) {
- Log(LogWarning, "cli", "Ignoring parameters: " + boost::algorithm::join(ap, " "));
- }
+ if (!ap.empty()) {
+ Log(LogWarning, "cli", "Ignoring parameters: " + boost::algorithm::join(ap, " "));
+ }
#ifdef _WIN32
//TODO: Add Windows support
- Log(LogInformation, "cli", "This command is not available on Windows.");
+ Log(LogInformation, "cli", "This command is not available on Windows.");
#else
std::vector<String> enabled_features;
std::vector<String> available_features;