mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 14:56:15 +02:00
0fa08b4516
Previously, there were two mostly-identical value printers -- one in `libexpr/eval.cc` (which didn't force values) and one in `libcmd/repl.cc` (which did force values and also printed ANSI color codes). This PR unifies both of these printers into `print.cc` and provides a `PrintOptions` struct for controlling the output, which allows for toggling whether values are forced, whether repeated values are tracked, and whether ANSI color codes are displayed. Additionally, `PrintOptions` allows tuning the maximum number of attributes, list items, and bytes in a string that will be displayed; this makes it ideal for contexts where printing too much output (e.g. all of Nixpkgs) is distracting. (As requested by @roberth in https://github.com/NixOS/nix/pull/9554#issuecomment-1845095735) Please read the tests for example output. Future work: - It would be nice to provide this function as a builtin, perhaps `builtins.toStringDebug` -- a printing function that never fails would be useful when debugging Nix code. - It would be nice to support customizing `PrintOptions` members on the command line, e.g. `--option to-string-max-attrs 1000`. |
||
---|---|---|
.. | ||
flake | ||
primops | ||
value | ||
attr-path.cc | ||
attr-path.hh | ||
attr-set.cc | ||
attr-set.hh | ||
eval-cache.cc | ||
eval-cache.hh | ||
eval-inline.hh | ||
eval-settings.cc | ||
eval-settings.hh | ||
eval.cc | ||
eval.hh | ||
fetchurl.nix | ||
function-trace.cc | ||
function-trace.hh | ||
gc-small-vector.hh | ||
get-drvs.cc | ||
get-drvs.hh | ||
imported-drv-to-derivation.nix | ||
json-to-value.cc | ||
json-to-value.hh | ||
lexer.l | ||
local.mk | ||
nix-expr.pc.in | ||
nixexpr.cc | ||
nixexpr.hh | ||
parser.y | ||
paths.cc | ||
primops.cc | ||
primops.hh | ||
print-options.hh | ||
print.cc | ||
print.hh | ||
search-path.cc | ||
search-path.hh | ||
symbol-table.hh | ||
value-to-json.cc | ||
value-to-json.hh | ||
value-to-xml.cc | ||
value-to-xml.hh | ||
value.hh |