1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 01:51:47 +02:00

Merge pull request #5840 from tweag/balsoft/nix-repl-show-trace

nix repl: fix --show-trace and add the ability to set trace display
This commit is contained in:
Eelco Dolstra 2022-01-03 20:41:59 +01:00 committed by GitHub
commit 70dfcbbb37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 3 deletions

View file

@ -25,7 +25,7 @@ const string & BaseError::calcWhat() const
err.name = sname();
std::ostringstream oss;
showErrorInfo(oss, err, false);
showErrorInfo(oss, err, loggerSettings.showTrace);
what_ = oss.str();
return *what_;

View file

@ -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);