mirror of
https://github.com/NixOS/nix.git
synced 2025-12-18 15:01:08 +01:00
Redirect some Nix command outputs to a pager
Make `nix search`, `nix flake show` and `nix flake metadata` pipe their output into a pager to make their result easier to visualise.
This commit is contained in:
parent
9c6ede85fc
commit
d7a9e5346c
2 changed files with 4 additions and 0 deletions
|
|
@ -167,6 +167,8 @@ struct CmdFlakeMetadata : FlakeCommand, MixJSON
|
||||||
auto lockedFlake = lockFlake();
|
auto lockedFlake = lockFlake();
|
||||||
auto & flake = lockedFlake.flake;
|
auto & flake = lockedFlake.flake;
|
||||||
|
|
||||||
|
RunPager pager;
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
if (flake.description)
|
if (flake.description)
|
||||||
|
|
@ -1128,6 +1130,7 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
||||||
Activity act(*logger, lvlInfo, actUnknown,
|
Activity act(*logger, lvlInfo, actUnknown,
|
||||||
fmt("evaluating '%s'", concatStringsSep(".", attrPathS)));
|
fmt("evaluating '%s'", concatStringsSep(".", attrPathS)));
|
||||||
|
|
||||||
|
std::optional<RunPager> pager = json ? std::nullopt : std::optional<RunPager>(RunPager());
|
||||||
try {
|
try {
|
||||||
auto recurse = [&]()
|
auto recurse = [&]()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ struct CmdSearch : InstallableValueCommand, MixJSON
|
||||||
|
|
||||||
void run(ref<Store> store, ref<InstallableValue> installable) override
|
void run(ref<Store> store, ref<InstallableValue> installable) override
|
||||||
{
|
{
|
||||||
|
RunPager pager;
|
||||||
settings.readOnlyMode = true;
|
settings.readOnlyMode = true;
|
||||||
evalSettings.enableImportFromDerivation.setDefault(false);
|
evalSettings.enableImportFromDerivation.setDefault(false);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue