Skip to content

Commit

Permalink
Document echo_via_pager + generator usage
Browse files Browse the repository at this point in the history
  • Loading branch information
stefreak committed Jan 8, 2018
1 parent 532aa83 commit dda3aec
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ Example:
click.echo_via_pager('\n'.join('Line %d' % idx
for idx in range(200)))

If you want to use the pager for a lot of text, especially if generating everything in advance would take a lot of time, you can pass a generator (or generator function) instead of a string:

.. click:example::
def _generate_output():
for idx in range(50000):
yield "Line %d\n" % idx

@click.command()
def less():
click.echo_via_pager(_generate_output())


Screen Clearing
---------------
Expand Down

0 comments on commit dda3aec

Please sign in to comment.