aboutsummaryrefslogtreecommitdiff
path: root/src/libmain
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmain')
-rw-r--r--src/libmain/common-args.cc9
-rw-r--r--src/libmain/shared.hh3
2 files changed, 7 insertions, 5 deletions
diff --git a/src/libmain/common-args.cc b/src/libmain/common-args.cc
index 75feccbed..12ce289c5 100644
--- a/src/libmain/common-args.cc
+++ b/src/libmain/common-args.cc
@@ -1,4 +1,5 @@
#include "common-args.hh"
+#include "args/root.hh"
#include "globals.hh"
#include "loggers.hh"
@@ -34,21 +35,21 @@ MixCommonArgs::MixCommonArgs(const std::string & programName)
.description = "Set the Nix configuration setting *name* to *value* (overriding `nix.conf`).",
.category = miscCategory,
.labels = {"name", "value"},
- .handler = {[](std::string name, std::string value) {
+ .handler = {[this](std::string name, std::string value) {
try {
globalConfig.set(name, value);
} catch (UsageError & e) {
- if (!completions)
+ if (!getRoot().completions)
warn(e.what());
}
}},
- .completer = [](size_t index, std::string_view prefix) {
+ .completer = [](AddCompletions & completions, 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 (s.first.starts_with(prefix))
- completions->add(s.first, fmt("Set the `%s` setting.", s.first));
+ completions.add(s.first, fmt("Set the `%s` setting.", s.first));
}
}
});
diff --git a/src/libmain/shared.hh b/src/libmain/shared.hh
index 2b15d3368..a7810f77c 100644
--- a/src/libmain/shared.hh
+++ b/src/libmain/shared.hh
@@ -3,6 +3,7 @@
#include "util.hh"
#include "args.hh"
+#include "args/root.hh"
#include "common-args.hh"
#include "path.hh"
#include "derived-path.hh"
@@ -58,7 +59,7 @@ template<class N> N getIntArg(const std::string & opt,
}
-struct LegacyArgs : public MixCommonArgs
+struct LegacyArgs : public MixCommonArgs, public RootArgs
{
std::function<bool(Strings::iterator & arg, const Strings::iterator & end)> parseArg;