Closed Schwitzd closed 3 weeks ago
Default behavior among all the CLI elements of beaupy
is not to raise on keyboard interrupt. If you'd prefer it to raise, you can set this behavior as follows:
from beaupy import select_multiple, Config
Config.raise_on_interrupt = True
try:
selected_apps = select_multiple(bloatware_detected, pagination=True, page_size=20)
except KeyboardInterrupt as ki:
raise SystemExit() from ki
Please let me know if this fits your use case.
EDIT: For completeness, I'd like to mention another config option Config.raise_on_escape
, which controls whether beaupy
raises on the press of the ESC key while in CLI context. This raises a custom exception - Abort
. The two config options in tandem can be used to differentiate between a "hard" exit in case of CTRL+C and a "soft" exit in case of ESC.
wooow so fast, exactly what I was looking for <3
I have this code snipped:
When I press CTRL+C during the selection the KeyboardInterrupt exception is bypassed.
I'm using the latest release of beaupy.
Cheers