1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-10 12:36:01 +01:00
This commit is contained in:
Eelco Dolstra 2020-05-10 21:50:32 +02:00
parent e0c19ee620
commit 0884f180f5
5 changed files with 23 additions and 27 deletions

View file

@ -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({