repl

command
v1.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

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 ¶

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL