repl: Allow :env outside of debug mode
Printing the current variables plus staticBaseEnv is useful Change-Id: Ide8bc26c1c6b4ec0b1d68767994ddac8891a649f
This commit is contained in:
+10
-8
@@ -544,6 +544,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||
<< " :bl <expr> Build a derivation, creating GC roots in the\n"
|
||||
<< " working directory\n"
|
||||
<< " :e, :edit <expr> Open package or function in $EDITOR\n"
|
||||
<< " :env Show env stack\n"
|
||||
<< " :i <expr> Build derivation, then install result into\n"
|
||||
<< " current profile\n"
|
||||
<< " :l, :load <path> Load Nix expression and add it to scope\n"
|
||||
@@ -566,7 +567,6 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||
std::cout
|
||||
<< "\n"
|
||||
<< " Debug mode commands\n"
|
||||
<< " :env Show env stack\n"
|
||||
<< " :bt, :backtrace Show trace stack\n"
|
||||
<< " :st Show current trace\n"
|
||||
<< " :st <idx> Change to another trace in the stack\n"
|
||||
@@ -588,14 +588,16 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||
}
|
||||
|
||||
else if (command == ":env") {
|
||||
if (!inDebugger)
|
||||
throw Error("env command is only available in debug mode (see %s)", "--debugger");
|
||||
auto traces = evaluator.debug->traces();
|
||||
for (const auto & [idx, i] : enumerate(traces)) {
|
||||
if (idx == debugTraceIndex) {
|
||||
printEnvBindings(state, i->expr, i->env);
|
||||
break;
|
||||
if (inDebugger) {
|
||||
auto traces = evaluator.debug->traces();
|
||||
for (const auto & [idx, i] : enumerate(traces)) {
|
||||
if (idx == debugTraceIndex) {
|
||||
printEnvBindings(state, i->expr, i->env);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printEnvBindings(state.ctx.symbols, *staticEnv, *env, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,3 +90,13 @@ they aren't the top level item being printed.
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Printing an environment with :env after adding a variable to the scope
|
||||
|
||||
nix-repl> foo = "bar"
|
||||
nix-repl> :env
|
||||
Env level 0
|
||||
static: foo
|
||||
|
||||
Env level 1
|
||||
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true
|
||||
|
||||
Reference in New Issue
Block a user