benthayer / git-gud

Wanna git gud? Then get git-gud, and git gud at git!
MIT License
401 stars 42 forks source link

Handle `KeyboardInterrupt` during `git gud explain` #333

Closed benthayer closed 3 years ago

benthayer commented 3 years ago

If the user types Ctrl-C when in the middle of the git gud explain, they get an ugly traceback. Instead, it would be better if no traceback showed up.

This can either be fixed in the GitGud.handle_explain function in __main__.py or in the BasicLevel.explain function in util/level_builder.py

Something like this would be enough

try:
    # something
except KeyboardInterrupt:
    exit()
vmdhhh commented 3 years ago

I tested it on my end. It works well with the way you mentioned @benthayer. I have made the change in #334. Please let me know if I am missing something.

benthayer commented 3 years ago

Yep, looks good! Thanks. Can you make sure the flake8 checks are passing? https://github.com/benthayer/git-gud/actions/runs/404322348

You can do pip install flake8 and then flake8 to run the checks for yourself

vmdhhh commented 3 years ago

Ah. I had it already, forgot to check. My bad sorry. Pushed again with correct formatting! @benthayer Please check whenever possible.