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

Directs output of 'inspect' to a pager (default: 'less'). #84

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

tgregg
Copy link
Contributor

@tgregg tgregg commented Feb 9, 2024

Description of changes:

Inspired by the CLI Guidelines (https://clig.dev/#output); also, I always pipe ion beta inspect to less, but usually after I've forgotten to do that and blown away my terminal by trying to inspect a huge file.

This PR directs output to the pager specified by the PAGER environment variable, or less -FIRX if the environment variable is not set. Note: a pager is not used if the output is not a TTY.

less -FIRX has the following behavior:

  • does not page if the content fills one screen (i.e., for small streams, the behavior does not change)
  • ignores case when you search
  • enables color and formatting (which we don't currently use, but could)
  • leaves the contents on the screen when less quits

Currently a pager is not used on Windows because the pager crate appears to be Unix-only. It looks like there may be some pure Rust pager implementations that we could probably use instead. I liked this one because it allows users to bring their own pager. Before going deeper into this I wanted to open this PR for discussion.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@zslayton
Copy link
Contributor

zslayton commented Feb 9, 2024

enables color and formatting (which we don't currently use, but could)

We actually do--all the comments in the Ion Text column are in a muted gray, and the column headers are bold:

image

Copy link
Contributor

@zslayton zslayton left a comment

Choose a reason for hiding this comment

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

🚀

@zslayton zslayton marked this pull request as ready for review February 9, 2024 15:24
@zslayton zslayton merged commit 6cf4431 into master Feb 9, 2024
7 checks passed
@zslayton zslayton deleted the inspect-to-pager branch February 9, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants