How to allow graceful control+c? #171
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi Idan 👋
It would be helpful if you could be more specific by what you mean by 'graceful control+c'. What do you want your CLI to do when a user presses For example, it is quite common for programs to stop running when prompt = TTY::Prompt.new(interrupt: -> { TTY::Exit.exit_with(:interrupt) }) Then applications that rely on the standard exit code can respond appropriately. Another option, if you do not wish to exit from your script is to, for example, capture the |
Beta Was this translation helpful? Give feedback.
-
I added a rescue TTY::Reader::InputInterrupt
puts pastel.red('Cancelled input. Data not saved')
end |
Beta Was this translation helpful? Give feedback.
I added a
rescue
clause on #execute in command file