2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2014-10-13 18:09:58 +02:00
|
|
|
|
|
|
|
#include "cli/featuredisablecommand.hpp"
|
2014-10-18 19:31:52 +02:00
|
|
|
#include "cli/featureutility.hpp"
|
2014-10-19 14:21:12 +02:00
|
|
|
#include "base/logger.hpp"
|
2014-10-13 18:09:58 +02:00
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
namespace po = boost::program_options;
|
|
|
|
|
|
|
|
REGISTER_CLICOMMAND("feature/disable", FeatureDisableCommand);
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
String FeatureDisableCommand::GetDescription() const
|
2014-10-13 18:09:58 +02:00
|
|
|
{
|
|
|
|
return "Disables specified Icinga 2 feature.";
|
|
|
|
}
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
String FeatureDisableCommand::GetShortDescription() const
|
2014-10-13 18:09:58 +02:00
|
|
|
{
|
|
|
|
return "disables specified feature";
|
|
|
|
}
|
|
|
|
|
2014-10-18 19:31:52 +02:00
|
|
|
std::vector<String> FeatureDisableCommand::GetPositionalSuggestions(const String& word) const
|
2014-10-13 18:09:58 +02:00
|
|
|
{
|
2014-10-21 18:35:43 +02:00
|
|
|
return FeatureUtility::GetFieldCompletionSuggestions(word, false);
|
2014-10-13 18:09:58 +02:00
|
|
|
}
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
int FeatureDisableCommand::GetMinArguments() const
|
2014-10-24 13:15:21 +02:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
int FeatureDisableCommand::GetMaxArguments() const
|
2014-10-24 13:15:21 +02:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
ImpersonationLevel FeatureDisableCommand::GetImpersonationLevel() const
|
2014-10-24 15:29:46 +02:00
|
|
|
{
|
|
|
|
return ImpersonateRoot;
|
|
|
|
}
|
|
|
|
|
2014-10-13 18:09:58 +02:00
|
|
|
/**
|
|
|
|
* The entry point for the "feature disable" CLI command.
|
|
|
|
*
|
|
|
|
* @returns An exit status.
|
|
|
|
*/
|
|
|
|
int FeatureDisableCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
|
|
|
|
{
|
2014-10-15 08:45:58 +02:00
|
|
|
if (ap.empty()) {
|
|
|
|
Log(LogCritical, "cli", "Cannot disable feature(s). Name(s) are missing!");
|
|
|
|
return 0;
|
|
|
|
}
|
2014-10-13 18:09:58 +02:00
|
|
|
|
2014-10-21 18:35:43 +02:00
|
|
|
return FeatureUtility::DisableFeatures(ap);
|
2014-10-13 18:09:58 +02:00
|
|
|
}
|