Skip to content

Add interactive arrow-key Yes/No prompt#283

Merged
bguidolim merged 3 commits intomainfrom
bruno/interactive-yes-no-prompt
Mar 24, 2026
Merged

Add interactive arrow-key Yes/No prompt#283
bguidolim merged 3 commits intomainfrom
bruno/interactive-yes-no-prompt

Conversation

@bguidolim
Copy link
Copy Markdown
Collaborator

@bguidolim bguidolim commented Mar 24, 2026

Summary

Upgrades askYesNo from plain text input (type y or n) to an interactive horizontal arrow-key selector, consistent with the existing singleSelect and multiSelect UX. Also refactors shared raw terminal infrastructure to eliminate duplication across all three interactive prompts, and standardizes hint line placement and style.

Changes

  • Add interactiveYesNo with horizontal › Yes No layout using left/right arrows, y/n shortcuts, Enter/Space to confirm
  • Extract withRawTerminal(_:) helper replacing 3 duplicated raw terminal setup/teardown blocks
  • Extract readCSIArrowKey() helper replacing 3 duplicated CSI escape sequence parsers
  • Add stored isInteractiveTerminal property replacing 3 identical TTY checks
  • Move multi-select keyboard hint from top (inline prose) to bottom (dim with · separators), matching single-select and yes/no style
  • Non-TTY fallback preserves existing [Y/n] text input behavior — all 10 call sites unchanged

Test plan

  • swift test passes locally (866 tests)
  • swiftformat --lint . and swiftlint pass without violations
  • Affected commands verified with a real pack (e.g. mcs sync, mcs cleanup, mcs pack remove, mcs doctor --fix)

- Replace text-based askYesNo with horizontal arrow-key selector on TTY (left/right toggle, y/n shortcuts, non-TTY fallback unchanged)
- Extract withRawTerminal, readCSIArrowKey, and isInteractiveTerminal helpers to eliminate duplicated raw terminal setup across all three interactive prompts
- Relocate keyboard hint from top (inline prose) to bottom (dim with · separators)
- Matches the hint position and style used by single-select and yes/no prompts
@bguidolim bguidolim merged commit 884a2c0 into main Mar 24, 2026
4 checks passed
@bguidolim bguidolim deleted the bruno/interactive-yes-no-prompt branch March 24, 2026 18:19
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