aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Bereknyei <tomberek@gmail.com>2022-05-18 21:33:41 -0400
committerTom Bereknyei <tomberek@gmail.com>2022-05-18 21:36:50 -0400
commit7534798eedb696226101f2c8793ba9ace049f5e4 (patch)
tree0a5b21584af3f8e2bc435ddb6a9f916d66cfab0c
parent9f8c1183fa10aa9d95bce0ca2f3337532ad7981b (diff)
refactor: factor out getValue
-rw-r--r--src/nix/repl.cc28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index a1b42b760..cae76bb5d 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -920,18 +920,22 @@ struct CmdRepl : InstallablesCommand
void run(ref<Store> store) override
{
auto state = getEvalState();
- auto repl = std::make_unique<NixRepl>(searchPath, openStore(),state
- ,[&]()->NixRepl::AnnotatedValues{
- auto installables = load();
- NixRepl::AnnotatedValues values;
- for (auto & installable: installables){
- auto [val, pos] = installable->toValue(*state);
- auto what = installable->what();
- values.push_back( {val,what} );
- }
- return values;
- }
- );
+ auto getValues = [&]()->NixRepl::AnnotatedValues{
+ auto installables = load();
+ NixRepl::AnnotatedValues values;
+ for (auto & installable: installables){
+ auto [val, pos] = installable->toValue(*state);
+ auto what = installable->what();
+ values.push_back( {val,what} );
+ }
+ return values;
+ };
+ auto repl = std::make_unique<NixRepl>(
+ searchPath,
+ openStore(),
+ state,
+ getValues
+ );
repl->autoArgs = getAutoArgs(*repl->state);
repl->mainLoop();
}