Show an interruptible auto-continue countdown

SolidGroundUX DocumentationSolidGroundUX
NL

fn: ask_dlg_autocontinue

Purpose

Display a short countdown prompt that continues automatically unless the user intervenes.

Behavior

  • Writes countdown status and optional legend to /dev/tty.
  • Allows Enter or any key to continue depending on options.
  • Optionally supports redo, cancel, and pause/resume keys.
  • Returns distinct codes so callers can map user intervention to decisions.

Options

  • --seconds COUNT — Countdown length in seconds. Defaults to 5.
  • --message TEXT — Message displayed above the countdown.
  • --legend TEXT — Custom legend text. When omitted, the standard key legend is built from the enabled interaction options.
  • --redo — Enables R as redo, returning 3.
  • --again — Enables A as again/repeat, returning 3.
  • --cancel — Enables C or Esc as cancel, returning 2.
  • --pause — Enables P or Space to pause/resume the countdown.
  • --anykey — Allows any key to continue immediately.
  • --hidelegend — Suppresses the key legend line.

Output

Writes countdown UI to /dev/tty.

Returns

  • 0 when the user continues explicitly.
  • 1 when the countdown expires.
  • 2 when the user cancels.
  • 3 when the user requests redo/again.

Usage

  # Continue automatically after a short countdown.
  ask_dlg_autocontinue --seconds 5 --message "Next step"

  # Allow cancellation, redo, and pause; handle the return status.
  ask_dlg_autocontinue --seconds 10 --message "Continuing deployment" \
      --redo --cancel --pause
  result=$?
  case "$result" in
      0) : ;; # continued explicitly
      1) : ;; # countdown expired
      2) : ;; # cancelled
      3) : ;; # redo requested
  esac