1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-18 00:12:43 +01:00
nix/src/libcmd
Rebecca Turner 0fa08b4516
Unify and refactor value printing
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`.
2024-01-11 16:34:36 -08:00
..
built-path.cc use std::tie() for macro-generated operators 2023-12-19 19:32:16 +01:00
built-path.hh Merge pull request #6236 from obsidiansystems/store-dir-config 2023-12-01 15:38:14 +01:00
command-installable-value.cc Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
command-installable-value.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
command.cc Improve the error message for “multicommands” commands (#9510) 2023-12-06 13:13:45 +00:00
command.hh Improve the error message for “multicommands” commands (#9510) 2023-12-06 13:13:45 +00:00
common-eval-args.cc Document each store type on its own page 2023-12-01 01:27:52 +01:00
common-eval-args.hh libcmd: lookupFileArg(): add baseDir 2023-11-07 13:24:01 -05:00
editor-for.cc Combine AbstractPos, PosAdapter, and Pos 2024-01-08 10:59:41 -08:00
editor-for.hh Combine AbstractPos, PosAdapter, and Pos 2024-01-08 10:59:41 -08:00
installable-attr-path.cc Fixing #7479 2023-08-18 11:44:00 -04:00
installable-attr-path.hh Split up util.{hh,cc} 2023-11-05 12:20:02 -05:00
installable-derived-path.cc Fixing #7479 2023-08-18 11:44:00 -04:00
installable-derived-path.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
installable-flake.cc remove lazy-pos forceValue 2023-12-19 19:32:16 +01:00
installable-flake.hh Rename 'resolvedRef' to 'lockedRef' 2023-07-03 12:23:57 +02:00
installable-value.cc Combine AbstractPos, PosAdapter, and Pos 2024-01-08 10:59:41 -08:00
installable-value.hh Make more string values work as installables 2023-05-15 09:03:38 -04:00
installables.cc nix shell: reflect command line order in PATH order 2023-12-21 10:56:19 -08:00
installables.hh nix shell: reflect command line order in PATH order 2023-12-21 10:56:19 -08:00
legacy.cc Move command plugin interface to libnixcmd 2021-01-26 06:22:24 -05:00
legacy.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
local.mk Only link with -pthread on Unix 2024-01-10 20:38:39 -05:00
markdown.cc Make lowdown optional 2024-01-08 20:37:42 +01:00
markdown.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
nix-cmd.pc.in Fix building with GCC 9 2023-02-10 18:38:57 +01:00
repl.cc Unify and refactor value printing 2024-01-11 16:34:36 -08:00
repl.hh Clean up SearchPath 2023-07-09 23:22:22 -04:00