diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-05-10 20:32:21 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-05-10 20:32:21 +0200 |
commit | 91ddee6bf045b1c6144d14233abdb96127186ec3 (patch) | |
tree | 5c75576b453c177c3a43a422db1323cb7452b7f8 /src/libmain | |
parent | 14a3a62bfca6c572b9a415cfa80cdbd7ad4326b3 (diff) |
nix: Implement basic bash completion
Diffstat (limited to 'src/libmain')
-rw-r--r-- | src/libmain/common-args.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libmain/common-args.cc b/src/libmain/common-args.cc index 51e199ea5..f3f508ff4 100644 --- a/src/libmain/common-args.cc +++ b/src/libmain/common-args.cc @@ -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()); } }}, }); |