nix-super/src/nix/show-config.cc

41 lines
897 B
C++
Raw Normal View History

#include "command.hh"
#include "common-args.hh"
#include "shared.hh"
#include "store-api.hh"
#include "json.hh"
using namespace nix;
2017-04-24 15:21:36 +03:00
struct CmdShowConfig : Command, MixJSON
{
CmdShowConfig()
{
}
std::string name() override
{
return "show-config";
}
std::string description() override
{
return "show the Nix configuration";
}
void run() override
{
if (json) {
// FIXME: use appropriate JSON types (bool, ints, etc).
2017-11-14 15:27:01 +02:00
JSONObject jsonObj(std::cout);
globalConfig.toJSON(jsonObj);
} else {
std::map<std::string, Config::SettingInfo> settings;
globalConfig.getSettings(settings);
for (auto & s : settings)
std::cout << s.first + " = " + s.second.value + "\n";
}
}
};
static RegisterCommand r1(make_ref<CmdShowConfig>());