libcmd: add an aio root to completeFlakeRef
the other completers already inherit one through EvalState. all of them eventually need it since completing a flake ref may require network io. Change-Id: Ie664a129a68457a6f0908d226057d7d7fb610ae4
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "lix/libcmd/common-eval-args.hh"
|
||||
#include "lix/libstore/path.hh"
|
||||
#include "lix/libexpr/flake/lockfile.hh"
|
||||
#include "lix/libutil/async.hh"
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -357,7 +358,9 @@ void completeFlakeInputPath(
|
||||
const std::vector<FlakeRef> & flakeRefs,
|
||||
std::string_view prefix);
|
||||
|
||||
void completeFlakeRef(AddCompletions & completions, ref<Store> store, std::string_view prefix);
|
||||
void completeFlakeRef(
|
||||
AsyncIoRoot & aio, AddCompletions & completions, ref<Store> store, std::string_view prefix
|
||||
);
|
||||
|
||||
void completeFlakeRefWithFragment(
|
||||
AddCompletions & completions,
|
||||
|
||||
@@ -155,7 +155,7 @@ MixEvalArgs::MixEvalArgs()
|
||||
fetchers::overrideRegistry(from.input, to.input, extraAttrs);
|
||||
}},
|
||||
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
||||
completeFlakeRef(completions, aio().blockOn(openStore()), prefix);
|
||||
completeFlakeRef(aio(), completions, aio().blockOn(openStore()), prefix);
|
||||
}}
|
||||
});
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "lix/libcmd/installable-derived-path.hh"
|
||||
#include "lix/libcmd/installable-attr-path.hh"
|
||||
#include "lix/libcmd/installable-flake.hh"
|
||||
#include "lix/libutil/async.hh"
|
||||
#include "lix/libutil/logging.hh"
|
||||
#include "lix/libstore/outputs-spec.hh"
|
||||
#include "lix/libcmd/command.hh"
|
||||
@@ -90,7 +91,7 @@ MixFlakeOptions::MixFlakeOptions()
|
||||
completions, *getEvaluator()->begin(aio()), getFlakeRefsForCompletion(), prefix
|
||||
);
|
||||
} else if (n == 1) {
|
||||
completeFlakeRef(completions, getEvaluator()->store, prefix);
|
||||
completeFlakeRef(aio(), completions, getEvaluator()->store, prefix);
|
||||
}
|
||||
}}
|
||||
});
|
||||
@@ -139,7 +140,7 @@ MixFlakeOptions::MixFlakeOptions()
|
||||
}
|
||||
}},
|
||||
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
||||
completeFlakeRef(completions, getEvaluator()->store, prefix);
|
||||
completeFlakeRef(aio(), completions, getEvaluator()->store, prefix);
|
||||
}}
|
||||
});
|
||||
}
|
||||
@@ -282,7 +283,7 @@ void completeFlakeRefWithFragment(
|
||||
try {
|
||||
auto hash = prefix.find('#');
|
||||
if (hash == std::string::npos) {
|
||||
completeFlakeRef(completions, evaluator->store, prefix);
|
||||
completeFlakeRef(evalState.aio, completions, evaluator->store, prefix);
|
||||
} else {
|
||||
completions.setType(AddCompletions::Type::Attrs);
|
||||
|
||||
@@ -349,7 +350,9 @@ void completeFlakeRefWithFragment(
|
||||
}
|
||||
}
|
||||
|
||||
void completeFlakeRef(AddCompletions & completions, ref<Store> store, std::string_view prefix)
|
||||
void completeFlakeRef(
|
||||
AsyncIoRoot & aio, AddCompletions & completions, ref<Store> store, std::string_view prefix
|
||||
)
|
||||
{
|
||||
if (!experimentalFeatureSettings.isEnabled(Xp::Flakes))
|
||||
return;
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ struct CmdBundle : InstallableCommand
|
||||
.labels = {"flake-url"},
|
||||
.handler = {&bundler},
|
||||
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
||||
completeFlakeRef(completions, getStore(), prefix);
|
||||
completeFlakeRef(aio(), completions, getStore(), prefix);
|
||||
}}
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ public:
|
||||
.optional = true,
|
||||
.handler = {&flakeUrl},
|
||||
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
||||
completeFlakeRef(completions, getStore(), prefix);
|
||||
completeFlakeRef(aio(), completions, getStore(), prefix);
|
||||
}}
|
||||
});
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
.labels={"flake-url"},
|
||||
.handler={&flakeUrl},
|
||||
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
||||
completeFlakeRef(completions, getStore(), prefix);
|
||||
completeFlakeRef(aio(), completions, getStore(), prefix);
|
||||
}}
|
||||
});
|
||||
expectArgs({
|
||||
|
||||
+1
-1
@@ -184,7 +184,7 @@ struct CmdRegistryPin : RegistryCommand, EvalCommand
|
||||
.optional = true,
|
||||
.handler = {&locked},
|
||||
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
||||
completeFlakeRef(completions, getStore(), prefix);
|
||||
completeFlakeRef(aio(), completions, getStore(), prefix);
|
||||
}}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user