diff options
Diffstat (limited to 'src/libmain')
-rw-r--r-- | src/libmain/common-args.cc | 12 | ||||
-rw-r--r-- | src/libmain/loggers.cc | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/libmain/common-args.cc b/src/libmain/common-args.cc index 051668e53..09f4cd133 100644 --- a/src/libmain/common-args.cc +++ b/src/libmain/common-args.cc @@ -34,9 +34,19 @@ MixCommonArgs::MixCommonArgs(const string & programName) try { globalConfig.set(name, value); } catch (UsageError & e) { - warn(e.what()); + 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({ diff --git a/src/libmain/loggers.cc b/src/libmain/loggers.cc index fa18f991d..0a7291780 100644 --- a/src/libmain/loggers.cc +++ b/src/libmain/loggers.cc @@ -1,12 +1,13 @@ #include "loggers.hh" #include "progress-bar.hh" +#include "util.hh" namespace nix { LogFormat defaultLogFormat = LogFormat::raw; LogFormat parseLogFormat(const std::string & logFormatStr) { - if (logFormatStr == "raw") + if (logFormatStr == "raw" || getEnv("NIX_GET_COMPLETIONS")) return LogFormat::raw; else if (logFormatStr == "raw-with-logs") return LogFormat::rawWithLogs; |