kart icon indicating copy to clipboard operation
kart copied to clipboard

Add output pager to verbose commands

Open craigds opened this issue 5 years ago • 2 comments

This came up as part of #48. Some commands generate a lot of output, and mostly we don't pipe them to a pager at the moment.

Some of our commands exec git directly, so those may use a pager already, but over time more of the commands will probably be directly implemented in sno rather than execcing git.

We should add an output pager (presumably usually less) and ways of customising it.

craigds avatar Apr 16 '20 21:04 craigds

Looks like Click already has a solution for this (and further down the same page, "Launching Editors") 👏

We should start by trying that out

rcoup avatar Apr 21 '20 10:04 rcoup

LGTM. So to implement that, we need to:

  • change all the output-format functions to yield click.style(s, ...) everywhere rather than click.secho(s, ...)
  • make diff_with_writer responsible for resolving output paths to file objects, rather than the individual output-format functions
  • make diff_with_writer send generated output to a click.echo_via_pager(...)

Other (than show/diff) commands are probably a bit simpler but also in less need of a pager. log already has a pager because it execs git directly

craigds avatar Apr 30 '20 20:04 craigds