mirror of
https://github.com/NixOS/nix.git
synced 2025-11-10 12:36:01 +01:00
Simplify
This commit is contained in:
parent
e0c19ee620
commit
0884f180f5
5 changed files with 23 additions and 27 deletions
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue