]> granicus.if.org Git - icinga2/blob - lib/cli/featuredisablecommand.cpp
ApiListener#ApiTimerHandler(): delete all replayed logs
[icinga2] / lib / cli / featuredisablecommand.cpp
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/)      *
4  *                                                                            *
5  * This program is free software; you can redistribute it and/or              *
6  * modify it under the terms of the GNU General Public License                *
7  * as published by the Free Software Foundation; either version 2             *
8  * of the License, or (at your option) any later version.                     *
9  *                                                                            *
10  * This program is distributed in the hope that it will be useful,            *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
13  * GNU General Public License for more details.                               *
14  *                                                                            *
15  * You should have received a copy of the GNU General Public License          *
16  * along with this program; if not, write to the Free Software Foundation     *
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
18  ******************************************************************************/
19
20 #include "cli/featuredisablecommand.hpp"
21 #include "cli/featureutility.hpp"
22 #include "base/logger.hpp"
23
24 using namespace icinga;
25 namespace po = boost::program_options;
26
27 REGISTER_CLICOMMAND("feature/disable", FeatureDisableCommand);
28
29 String FeatureDisableCommand::GetDescription() const
30 {
31         return "Disables specified Icinga 2 feature.";
32 }
33
34 String FeatureDisableCommand::GetShortDescription() const
35 {
36         return "disables specified feature";
37 }
38
39 std::vector<String> FeatureDisableCommand::GetPositionalSuggestions(const String& word) const
40 {
41         return FeatureUtility::GetFieldCompletionSuggestions(word, false);
42 }
43
44 int FeatureDisableCommand::GetMinArguments() const
45 {
46         return 1;
47 }
48
49 int FeatureDisableCommand::GetMaxArguments() const
50 {
51         return -1;
52 }
53
54 ImpersonationLevel FeatureDisableCommand::GetImpersonationLevel() const
55 {
56         return ImpersonateRoot;
57 }
58
59 /**
60  * The entry point for the "feature disable" CLI command.
61  *
62  * @returns An exit status.
63  */
64 int FeatureDisableCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
65 {
66         if (ap.empty()) {
67                 Log(LogCritical, "cli", "Cannot disable feature(s). Name(s) are missing!");
68                 return 0;
69         }
70
71         return FeatureUtility::DisableFeatures(ap);
72 }