command
Version:
v1.7.2
Opens a new window with list of versions in this module.
Published: Feb 26, 2026
License: AGPL-3.0
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
Shell/REPL Example (The Infinite Loop)
This example demonstrates a interactive command-line application (a "Shell") that uses Escalation Mode to capture Ctrl+C without quitting.
It showcases:
- Interrupt Capturing:
Ctrl+C emits a ClearLineEvent instead of cancelling the context.
- Input Resilience: The input reader remains active on Windows even after multiple interruputs.
- Custom Shutdown Commands: Explicitly handling
exit or quit to trigger a graceful shutdown.
- Force Exit Safety Net: Mashing
Ctrl+C N times will still kill the process if it hangs.
🎮 Controls
Ctrl+C (1st to N-1th): Clears the current line (emits lifecycle/clear-line).
Ctrl+C (N-th): Force Exit (Immediate Kill).
exit / quit: Graceful shutdown.
Implementation
See main.go for the full implementation, specifically:
lifecycle.WithForceExit(3): Configures the shell to allow 2 "clears" and kill on the 3rd interrupt.
router.HandleFunc("lifecycle/clear-line", ...): UI reaction to the interrupt.
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.