Skip to content

Commit

Permalink
refactor: factor out getValue
Browse files Browse the repository at this point in the history
  • Loading branch information
tomberek committed May 19, 2022
1 parent 9f8c118 commit 7534798
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/nix/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 7534798

Please sign in to comment.