feat: add --key flag to send for named key sequences#6
Merged
Conversation
yoink send <alias> --key <name> resolves human-readable key names to their PTY byte sequences before sending, eliminating the need for raw \x1b escapes. Supported keys: arrow keys (up/down/left/right), navigation (home/end/pageup/ pagedown/delete/insert), basic keys (enter/tab/backspace/escape), ctrl combos (ctrl+a through ctrl+]), and function keys (f1–f12). Names are case-insensitive and common aliases are supported (esc, del, pgup, pgdn). --key implies --no-enter since key sequences are complete without a newline. --key and text input are mutually exclusive. Adds 35 tests in services/keys_test.go covering all key categories, aliases, case-insensitivity, and unknown key error handling.
Covers plain text, multi-word joining, --no-enter passthrough, --key resolution (including case-insensitivity), implicit no-enter for key sequences, and error cases (mutual exclusivity, unknown key).
StructLint — All checks passed61 rules validated against
|
There was a problem hiding this comment.
Core Changes
- Implements a new
--keyflag for theyoink sendcommand, allowing users to send named key sequences (e.g.,up,ctrl+c,f1) instead of plain text. - Introduces a
resolveInputhelper function to handle the logic for determining input (plain text or key sequence) and whether a trailing newline (--no-enter) should be implied. - Adds a new
services/keys.gofile containing a lookup table for common key names and their corresponding PTY byte sequences, along with aResolveKeyfunction.
Concerns
Verdict
Approve: The changes introduce a useful feature, are well-implemented, and include comprehensive unit tests. No critical issues were found.
Code review performed by GEMINI - gemini-2.5-flash.
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
--key <name>flag toyoink sendfor sending named key sequences (arrow keys, ctrl combos, function keys, navigation) without raw escape sequences--keyimplies--no-enterand is mutually exclusive with text inputservices/keys.gowith aResolveKeyfunction and a lookup table of 35+ key names (case-insensitive, with common aliases likeesc,del,pgup)services/keys_test.gocovering all key categories, aliases, case-insensitivity, and error handlingactions/send_test.gocoveringresolveInput: plain text, multi-word join,--no-enter,--keyresolution, implicit no-enter, and error casesTest plan
go test ./...— 151 tests pass--key+ text → errorPageUp,CTRL+C,F1)--keyalways implies--no-enter(no trailing newline)