Skip to content

feat: add --key flag to send for named key sequences#6

Merged
machado144 merged 2 commits into
mainfrom
feat/send-key
Apr 3, 2026
Merged

feat: add --key flag to send for named key sequences#6
machado144 merged 2 commits into
mainfrom
feat/send-key

Conversation

@machado144

Copy link
Copy Markdown
Contributor

Summary

  • Adds --key <name> flag to yoink send for sending named key sequences (arrow keys, ctrl combos, function keys, navigation) without raw escape sequences
  • --key implies --no-enter and is mutually exclusive with text input
  • Adds services/keys.go with a ResolveKey function and a lookup table of 35+ key names (case-insensitive, with common aliases like esc, del, pgup)
  • 35 unit tests in services/keys_test.go covering all key categories, aliases, case-insensitivity, and error handling
  • 10 unit tests in actions/send_test.go covering resolveInput: plain text, multi-word join, --no-enter, --key resolution, implicit no-enter, and error cases

Test plan

  • go test ./... — 151 tests pass
  • --key + text → error
  • Unknown key name → error with help hint
  • Case-insensitive key names (PageUp, CTRL+C, F1)
  • --key always implies --no-enter (no trailing newline)

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).
@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown

StructLint — All checks passed

61 rules validated against .structlint.yaml. No violations found.

View full run · Powered by StructLint

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core Changes

  • Implements a new --key flag for the yoink send command, allowing users to send named key sequences (e.g., up, ctrl+c, f1) instead of plain text.
  • Introduces a resolveInput helper 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.go file containing a lookup table for common key names and their corresponding PTY byte sequences, along with a ResolveKey function.

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.

@machado144 machado144 merged commit 9e5f6c4 into main Apr 3, 2026
5 checks passed
@machado144 machado144 deleted the feat/send-key branch April 4, 2026 14:27
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