Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect some Nix commands output to a pager #4972

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

thufschmitt
Copy link
Member

Make nix search, nix flake show and nix flake metadata pipe their
output into a pager to make their result easier to visualise.

Fix #4548

@edolstra
Copy link
Member

edolstra commented Jul 2, 2021

So the reason I didn't enable paging yet is that it can interact badly with the progress indicator. Maybe what we should do is show the progress indicator until the first output is written, then disable the progress indicator and start the pager.

@thufschmitt
Copy link
Member Author

So the reason I didn't enable paging yet is that it can interact badly with the progress indicator. Maybe what we should do is show the progress indicator until the first output is written, then disable the progress indicator and start the pager.

I’ve actually disabled the progress indicator altogether when using the pager (here). But waiting for the first output might be nicer (I’ve no idea how to do that though :) ).

@edolstra
Copy link
Member

edolstra commented Jul 2, 2021

Ideally we would use logger->writeToStdout / logger->cout everywhere (instead of std::cout), and then the progress bar logger can disable itself and start the pager the first time writeToStdout is called.

@thufschmitt
Copy link
Member Author

@edolstra I’ve rewritten the proxy mechanism in 8ad1ed5 to wrap a logger rather than being its own different thing. That way we can nicely intercept writeToStdout to start the pager as needed and tell the underlying pager not to dump arbitrary stuff on stdeer anymore

@edolstra edolstra added this to the nix-3.0 milestone Aug 30, 2021
@edolstra edolstra modified the milestones: nix-2.5, nix-2.6 Dec 13, 2021
@@ -0,0 +1,1180 @@
#include "command.hh"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You included the file by accident, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, yes. Thanks, fixed

@SuperSandro2000
Copy link
Member

Does less -R support the progress bar?

@thufschmitt
Copy link
Member Author

Does less -R support the progress bar?

-R wouldn’t. -r might, but it’s a bit hacky (and explicitly not recommended), so I’d rather not rely on that

@edolstra edolstra modified the milestones: nix-2.6, nix-2.7 Jan 24, 2022
@edolstra edolstra modified the milestones: nix-2.7, nix-2.8 Mar 3, 2022
@edolstra edolstra modified the milestones: nix-2.8, nix-2.9 Apr 14, 2022
@edolstra edolstra modified the milestones: nix-2.9, nix-2.10 May 27, 2022
@edolstra edolstra modified the milestones: nix-2.10, nix-2.11 Jul 11, 2022
@edolstra edolstra modified the milestones: nix-2.11, nix-2.12 Aug 25, 2022
@fricklerhandwerk fricklerhandwerk added the UX The way in which users interact with Nix. Higher level than UI. label Sep 9, 2022
@edolstra edolstra modified the milestones: nix-2.12, nix-2.13 Dec 6, 2022
@edolstra edolstra modified the milestones: nix-2.14, nix-2.15 Feb 28, 2023
@edolstra edolstra modified the milestones: nix-2.15, nix-2.16, nix-2.17 May 26, 2023
@github-actions github-actions bot added new-cli Relating to the "nix" command repl The Read Eval Print Loop, "nix repl" command and debugger labels Jun 8, 2023
Make `nix search`, `nix flake show` and `nix flake metadata` pipe their
output into a pager to make their result easier to visualise.
The `bar` logger sents a bunch of things to stderr that messes-up the
pager output
Rewrite the pager mechanism to make it a (parametrized) instance of `Logger`
rather than being a standalone thing.
The main interest of this is that we have more control over when to
actually start it and make the inner pager more quiet (only when
`writeToStdout` is called)
@thufschmitt
Copy link
Member Author

@edolstra friendly ping :)

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-08-04-nix-team-meeting-minutes-77/31487/1

@edolstra edolstra modified the milestones: nix-2.18, nix-2.19 Sep 20, 2023
@edolstra edolstra modified the milestones: nix-2.19, nix-2.20 Nov 20, 2023
@edolstra edolstra modified the milestones: nix-2.20, nix-2.21 Mar 4, 2024
@edolstra edolstra modified the milestones: nix-2.21, nix-2.22 Mar 11, 2024
@edolstra edolstra modified the milestones: nix-2.22, nix-2.23 Apr 23, 2024
@edolstra edolstra removed their assignment Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-cli Relating to the "nix" command repl The Read Eval Print Loop, "nix repl" command and debugger UX The way in which users interact with Nix. Higher level than UI.
Projects
Status: 🏁 Review
Development

Successfully merging this pull request may close these issues.

Revive piping output into the pager
5 participants