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:
parent
14a3a62bfc
commit
91ddee6bf0
9 changed files with 95 additions and 4 deletions
|
|
@ -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());
|
||||
}
|
||||
}},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue