Arrow-key picker for the VPN interface prompt - #31
Merged
Conversation
Replace the type-a-number prompt with an interactive menu when stdin and stdout are TTYs: up/down arrows move an inverse-video highlight with wraparound, Enter confirms, digits 1-9 still jump directly, and q, bare Escape, or Ctrl-C cancel. Raw mode is hand-rolled on termios via the existing libc dependency (no new crates); a Drop guard restores terminal attributes and cursor visibility on every exit path, with ISIG disabled so Ctrl-C cancels through the same cleanup instead of killing the process mid-raw-mode. Piped/non-TTY stdin keeps the numbered choice> fallback so scripts and tests are unaffected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
libcdependency — no new crates. A Drop guard restores terminal attributes and cursor visibility on every exit path; ISIG is disabled during selection so Ctrl-C cancels cleanly instead of leaving the terminal in raw mode.choice>fallback, so scripts and tests are unaffected.Test plan
cargo fmt --all -- --check,cargo clippy --all-targets -- -D warnings,cargo test --lib(27/27) pass.script): ↓↓+Enter selects the third interface and generates its PF rules; digit6jumps straight to the sixth;qand bare ESC cancel with "VPN interface selection cancelled" and the cursor/termios restored.echo 1 | lianyaohu --print-firewall(non-TTY) still uses the numbered prompt.🤖 Generated with Claude Code