Skip to content

Handle KeyboardInterrupt gracefully in CLI#128

Merged
holmboe merged 1 commit intomasterfrom
handle-KeyboardInterrupt
Feb 20, 2026
Merged

Handle KeyboardInterrupt gracefully in CLI#128
holmboe merged 1 commit intomasterfrom
handle-KeyboardInterrupt

Conversation

@holmboe
Copy link
Contributor

@holmboe holmboe commented Feb 20, 2026

Summary

  • Add exception handling for KeyboardInterrupt (Ctrl+C) to provide a clean exit instead of displaying a full traceback
  • Improves user experience when cancelling long-running operations like network requests

Changes

  • Catch KeyboardInterrupt in cli_entrypoint() function
  • Display "Operation cancelled by user." message to stderr
  • Exit with code 130 (standard Unix convention: 128 + SIGINT signal number 2)

Before

^CTraceback (most recent call last):
  File "/home/nn/code/github.com/dynamist/phabfive/.venv/bin/phabfive", line 10, in <module>
    sys.exit(cli_entrypoint())
  [... 50+ lines of traceback ...]
KeyboardInterrupt

After

^C
Operation cancelled by user.

Exit code: 130

Test Plan

  • Tested with mock KeyboardInterrupt simulation
  • Verified clean output message
  • Verified exit code 130
  • Confirmed other exceptions still propagate normally

🤖 Generated with Claude Code

Add exception handling for KeyboardInterrupt (Ctrl+C) to provide a clean
exit instead of displaying a full traceback. This improves user experience
when cancelling long-running operations like network requests.

- Catch KeyboardInterrupt in cli_entrypoint()
- Display "Operation cancelled by user." message
- Exit with code 130 (standard Unix convention for SIGINT)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@holmboe holmboe merged commit 197b5f7 into master Feb 20, 2026
15 checks passed
@holmboe holmboe deleted the handle-KeyboardInterrupt branch February 20, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant