diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-05-04 22:40:19 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-05-04 22:40:19 +0200 |
commit | a721a0b1140bf489d645f5d85737acafc1c57c65 (patch) | |
tree | f4b7df80fccc95b46fd3e8419375b563b466cfa4 /src/libutil/config.cc | |
parent | e9f10beed1a30fe80b315a9de4c4c2ab11527db8 (diff) |
Flag: Use designated initializers
Diffstat (limited to 'src/libutil/config.cc')
-rw-r--r-- | src/libutil/config.cc | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/libutil/config.cc b/src/libutil/config.cc index 7551d97d1..f03e444ec 100644 --- a/src/libutil/config.cc +++ b/src/libutil/config.cc @@ -177,12 +177,13 @@ void BaseSetting<T>::toJSON(JSONPlaceholder & out) template<typename T> void BaseSetting<T>::convertToArg(Args & args, const std::string & category) { - args.mkFlag() - .longName(name) - .description(description) - .arity(1) - .handler([=](std::vector<std::string> ss) { overriden = true; set(ss[0]); }) - .category(category); + args.addFlag({ + .longName = name, + .description = description, + .category = category, + .labels = {"value"}, + .handler = {[=](std::string s) { overriden = true; set(s); }}, + }); } template<> void BaseSetting<std::string>::set(const std::string & str) @@ -227,16 +228,18 @@ template<> std::string BaseSetting<bool>::to_string() const template<> void BaseSetting<bool>::convertToArg(Args & args, const std::string & category) { - args.mkFlag() - .longName(name) - .description(description) - .handler([=](std::vector<std::string> ss) { override(true); }) - .category(category); - args.mkFlag() - .longName("no-" + name) - .description(description) - .handler([=](std::vector<std::string> ss) { override(false); }) - .category(category); + args.addFlag({ + .longName = name, + .description = description, + .category = category, + .handler = {[=]() { override(true); }} + }); + args.addFlag({ + .longName = "no-" + name, + .description = description, + .category = category, + .handler = {[=]() { override(false); }} + }); } template<> void BaseSetting<Strings>::set(const std::string & str) |