-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Pager for help output #4201
Comments
Unsure if there is something newer/fancier but I was looking at the pager crate. We should probably detect if a pager is even needed and only show it if it is. The one downside is |
|
We also need to decide if paging should happen on We don't know enough about what the application is doing with |
what does take that on mean |
Implementing our own pager directly in clap |
|
Looks like Writing a wrapper around external pagers isn't too difficult, I just did it for another project. Generalizing it into a library will take some finessing though. |
My personal opinion on this issue as a whole is that it's not that hard to just use my own pager on the command line. If I want paged output, I just add My suggestion for that something is color/formatting support. Using an external pager usually turns off formatting, since the application doesn't see stdout going to a tty. Handling the pager in clap would allow the nicer output in a paged format. One problem with this is that, while My suggestion would be adding a One drawback I see to this approach is that a "full page" of output isn't a consistent unit. What might be a full page for the end user ends up being half a screen on the developer's machine, or vice versa, ending up with users needing to scroll the output themselves or having a slightly bigger binary. This also doesn't really account for really short terminals, like the ones in vscode, which need paging a lot more than usual. (though this is pretty much mitigated by these terminals having scrollback). It might be good to have a canonical recommendation for when application devs should turn this feature on in terms of lines of output. (might also be possible to have a lint/warning at build time if you have the feature disabled with >40 lines of help, not sure.) |
For you, maybe. Not all users use fish and not every user wants to think a priori whether they need to do
So I'm still not seeing the benefit of paying the cost of a fully built-in pager, especially one that the developer might not even be using in their application. |
how much of an increase in size are we talking about? A built-in pager could be an optional feature. A smaller app (fewer clap flags) is likely to be small in binary size, and it won't be affected because it won't use the feature. The apps with many flags are likely big enough not to notice a tiny size increase due to a built-in pager, so the devs can enable it. |
Right now, I'm leaning towards delegating to an external pager like git rather than having a rust-implemented pager. It keeps the binary size and compile times down and doesn't run into problems where people want to use a different pager and don't want to build two rust-implemented pagers (e.g. one reason ripgrep doesn't enable colors is it uses termcolor and clap v2 uses something else) To show how small this can be, https://github.com/epage/git-dive/blob/main/src/git_pager.rs is a re-implementation of git's pager logic. |
Thanks @epage, as long as both paging and colors work at the same time, life is great (i'm still hoping for v4 to restore color support :)). And as always, the moment I commented above, Twitter showed that delta (pager) project is trending... not sure if that could be used here, esp if there could ever be some sort of a "stable help syntax" that can be highlighted just like any code file. |
Please complete the following tasks
Clap Version
4.0
Describe your use case
As burntsushi put it
And as @phillyphil91 pointed out
Describe the solution you'd like
clig.dev's output guidelines suggest
Alternatives, if applicable
No response
Additional Context
This was split out of #4132 (comment)
The text was updated successfully, but these errors were encountered: