1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "cli/variablelistcommand.hpp"
4 #include "cli/variableutility.hpp"
5 #include "base/logger.hpp"
6 #include "base/application.hpp"
7 #include "base/convert.hpp"
8 #include "base/configobject.hpp"
9 #include "base/debug.hpp"
10 #include "base/objectlock.hpp"
11 #include "base/console.hpp"
12 #include <boost/algorithm/string/join.hpp>
13 #include <boost/algorithm/string/replace.hpp>
17 using namespace icinga;
18 namespace po = boost::program_options;
20 REGISTER_CLICOMMAND("variable/list", VariableListCommand);
22 String VariableListCommand::GetDescription() const
24 return "Lists all Icinga 2 variables.";
27 String VariableListCommand::GetShortDescription() const
29 return "lists all variables";
33 * The entry point for the "variable list" CLI command.
35 * @returns An exit status.
37 int VariableListCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
39 String varsfile = Configuration::VarsPath;
41 if (!Utility::PathExists(varsfile)) {
42 Log(LogCritical, "cli")
43 << "Cannot open variables file '" << varsfile << "'.";
44 Log(LogCritical, "cli", "Run 'icinga2 daemon -C' to validate config and generate the cache file.");
48 VariableUtility::PrintVariables(std::cout);