aboutsummaryrefslogtreecommitdiff
path: root/src/libmain/common-args.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-05-10 21:50:32 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-05-10 21:50:32 +0200
commit0884f180f5ca8a864e6db5256eaa10646e87d671 (patch)
tree2e9447915aa6894e73bd6e98ab95aa148519b3cf /src/libmain/common-args.cc
parente0c19ee620c53b52ca7cf69c19d414d782338be1 (diff)
Simplify
Diffstat (limited to 'src/libmain/common-args.cc')
-rw-r--r--src/libmain/common-args.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libmain/common-args.cc b/src/libmain/common-args.cc
index f3f508ff4..51a61f1ca 100644
--- a/src/libmain/common-args.cc
+++ b/src/libmain/common-args.cc
@@ -31,19 +31,21 @@ MixCommonArgs::MixCommonArgs(const string & programName)
.labels = {"name", "value"},
.handler = {[](std::string name, std::string value) {
try {
- if (auto prefix = needsCompletion(name)) {
- std::map<std::string, Config::SettingInfo> settings;
- globalConfig.getSettings(settings);
- for (auto & s : settings)
- if (hasPrefix(s.first, *prefix))
- completions->insert(s.first);
- }
globalConfig.set(name, value);
} catch (UsageError & e) {
if (!completions)
warn(e.what());
}
}},
+ .completer = [](size_t index, std::string_view prefix) {
+ if (index == 0) {
+ std::map<std::string, Config::SettingInfo> settings;
+ globalConfig.getSettings(settings);
+ for (auto & s : settings)
+ if (hasPrefix(s.first, prefix))
+ completions->insert(s.first);
+ }
+ }
});
addFlag({