1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-14 06:22:42 +01:00

nix: Implement basic bash completion

This commit is contained in:
Eelco Dolstra 2020-05-10 20:32:21 +02:00
parent 14a3a62bfc
commit 91ddee6bf0
9 changed files with 95 additions and 4 deletions

View file

@ -31,9 +31,17 @@ 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) {
warn(e.what());
if (!completions)
warn(e.what());
}
}},
});