amazon-ion / ion-cli

Apache License 2.0
31 stars 15 forks source link

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

Closed tgregg closed 6 months ago

tgregg commented 7 months ago

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:

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 commented 6 months ago

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