I'm using echo_via_pager() in my program to display the output through a pager. But while I'm in the pager if Ctrl-C is pressed then system.exit(1) is called, without giving me an opportunity to handle it.
I'm using this inside a repl and I'd like to have the ability to handle Ctrl-C.
Here's an example to reproduce:
import click
@click.command()
@click.option('--foo', prompt=True)
def cli(foo):
try:
click.echo_via_pager('foo=%s' % foo)
except click.Abort:
print('Tada!')
If you run this example and press Ctrl-C while in the pager, it will print 'Aborted!' and quit the program, I'd expect to see the message 'Tada!' instead.
I'm using
echo_via_pager()in my program to display the output through a pager. But while I'm in the pager if Ctrl-C is pressed then system.exit(1) is called, without giving me an opportunity to handle it.I'm using this inside a repl and I'd like to have the ability to handle Ctrl-C.
Here's an example to reproduce:
If you run this example and press Ctrl-C while in the pager, it will print 'Aborted!' and quit the program, I'd expect to see the message 'Tada!' instead.