From 186571965dccf57d15b9f37c1cca92a57187b7b3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 7 Jun 2017 18:41:20 +0200 Subject: Don't show flags from config settings in "nix --help" --- src/libutil/config.cc | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/libutil/config.cc') diff --git a/src/libutil/config.cc b/src/libutil/config.cc index 612fb6e68350..0682bcd5dbc3 100644 --- a/src/libutil/config.cc +++ b/src/libutil/config.cc @@ -115,11 +115,11 @@ void Config::toJSON(JSONObject & out) } } -void Config::convertToArgs(Args & args) +void Config::convertToArgs(Args & args, const std::string & category) { for (auto & s : _settings) if (!s.second.isAlias) - s.second.setting->convertToArg(args); + s.second.setting->convertToArg(args, category); } AbstractSetting::AbstractSetting( @@ -135,7 +135,7 @@ void AbstractSetting::toJSON(JSONPlaceholder & out) out.write(to_string()); } -void AbstractSetting::convertToArg(Args & args) +void AbstractSetting::convertToArg(Args & args, const std::string & category) { } @@ -146,9 +146,14 @@ void BaseSetting::toJSON(JSONPlaceholder & out) } template -void BaseSetting::convertToArg(Args & args) +void BaseSetting::convertToArg(Args & args, const std::string & category) { - args.mkFlag(0, name, {}, description, 1, [=](Strings ss) { set(*ss.begin()); }); + args.mkFlag() + .longName(name) + .description(description) + .arity(1) + .handler([=](Strings ss) { set(*ss.begin()); }) + .category(category); } template<> void BaseSetting::set(const std::string & str) @@ -191,10 +196,18 @@ template<> std::string BaseSetting::to_string() return value ? "true" : "false"; } -template<> void BaseSetting::convertToArg(Args & args) +template<> void BaseSetting::convertToArg(Args & args, const std::string & category) { - args.mkFlag(0, name, {}, description, 0, [=](Strings ss) { value = true; }); - args.mkFlag(0, "no-" + name, {}, description, 0, [=](Strings ss) { value = false; }); + args.mkFlag() + .longName(name) + .description(description) + .handler([=](Strings ss) { value = true; }) + .category(category); + args.mkFlag() + .longName("no-" + name) + .description(description) + .handler([=](Strings ss) { value = false; }) + .category(category); } template<> void BaseSetting::set(const std::string & str) -- cgit 1.4.1