aboutsummaryrefslogtreecommitdiff
path: root/src/nix/repl.cc
diff options
context:
space:
mode:
authorAlexander Bantyev <balsoft@balsoft.ru>2021-12-28 16:13:07 +0300
committerAlexander Bantyev <balsoft@balsoft.ru>2021-12-29 02:54:36 +0300
commita26351da02689d1e3ee562a6d89d93c12816e476 (patch)
tree2980911a028afdef01c44d0cada212c505fa5523 /src/nix/repl.cc
parent2dc29e0d932822baa50dbc3e81ae108382c39062 (diff)
Add ability to toggle show-trace from within the repl
Diffstat (limited to 'src/nix/repl.cc')
-rw-r--r--src/nix/repl.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 39a5a31de..a62ad66c2 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -430,7 +430,8 @@ bool NixRepl::processLine(string line)
<< " :t <expr> Describe result of evaluation\n"
<< " :u <expr> Build derivation, then start nix-shell\n"
<< " :doc <expr> Show documentation of a builtin function\n"
- << " :log <expr> Show logs for a derivation\n";
+ << " :log <expr> Show logs for a derivation\n"
+ << " :st [bool] Enable, disable or toggle showing traces for errors\n";
}
else if (command == ":a" || command == ":add") {
@@ -572,6 +573,18 @@ bool NixRepl::processLine(string line)
throw Error("value does not have documentation");
}
+ else if (command == ":st" || command == ":show-trace") {
+ if (arg == "false" || (arg == "" && loggerSettings.showTrace)) {
+ std::cout << "not showing error traces\n";
+ loggerSettings.showTrace = false;
+ } else if (arg == "true" || (arg == "" && !loggerSettings.showTrace)) {
+ std::cout << "showing error traces\n";
+ loggerSettings.showTrace = true;
+ } else {
+ throw Error("unexpected argument '%s' to %s", arg, command);
+ };
+ }
+
else if (command != "")
throw Error("unknown command '%1%'", command);