Add live-tennis-scores package - #238
Conversation
:tennis expands to a one-line summary of live tennis matches (names + per-set games) via a plain curl | grep | awk pipeline against the Live Tennis API. Requires a free LIVETENNIS_API_KEY; expands to a setup hint when the key is not set. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
smeech
left a comment
There was a problem hiding this comment.
I'm away at the moment so I'll let Copilot do its stuff and run the automated checks.
I note that it should run under WSL. Does that require a shell: addition to the code?
There was a problem hiding this comment.
Pull request overview
Adds a new Espanso Hub package, live-tennis-scores (v0.1.0), which expands :tennis into a compact one-line summary of up to 3 currently live tennis matches by calling the Live Tennis API and formatting results via a shell pipeline.
Changes:
- Adds the
:tennistrigger implementation inpackage.ymlusingcurl | grep | awk, with basic handling for missing API key and API-provided error responses. - Adds end-user documentation covering installation, API key setup, and a transparency note explaining the pipeline.
- Adds package metadata (
_manifest.yml) and MIT license file for the new package.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/live-tennis-scores/0.1.0/package.yml | Implements the :tennis trigger and the fetch/parse/format pipeline. |
| packages/live-tennis-scores/0.1.0/README.md | Documents usage, API key setup, and how the pipeline works. |
| packages/live-tennis-scores/0.1.0/_manifest.yml | Adds Hub metadata (name/title/description/tags/homepage). |
| packages/live-tennis-scores/0.1.0/LICENSE | Adds MIT license text for the package. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| curl -s -H "Authorization: Bearer $LIVETENNIS_API_KEY" "https://api.livetennisapi.com/api/public/v1/matches?status=live&limit=3" \ | ||
| | grep -o '"error":"[^"]*"\|"name":"[^"]*"\|"score":null\|"games":\[\[[0-9,]*\],\[[0-9,]*\]\]' \ | ||
| | awk -F'"' ' | ||
| /"error"/ { print "Live Tennis API error: " $4; err = 1; exit } | ||
| /"name"/ { n[++i] = $4 } | ||
| /"score":null/ { o = o (o ? " · " : "") n[1] " vs " n[2]; i = 0 } | ||
| /"games"/ { | ||
| g = $0; sub(/^"games":\[\[/, "", g); sub(/\]\]$/, "", g) | ||
| split(g, a, "\\],\\["); m = split(a[1], p, ","); split(a[2], q, ",") | ||
| s = "" | ||
| for (k = 1; k <= m; k++) if (p[k] != "") s = s " " p[k] "-" q[k] | ||
| if (s != "") s = s "*" | ||
| o = o (o ? " · " : "") n[1] s " vs " n[2]; i = 0 | ||
| } | ||
| END { if (!err) print (o ? o : "No live matches right now") }' |
| - `curl` (plus POSIX `grep`/`awk`/`sh`, preinstalled on Linux and macOS) | ||
| - Not tested on Windows (the pipeline assumes a POSIX shell; under WSL it | ||
| works) |
… WSLENV) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Good question — the answer is "yes, but only as a documented local edit, not in the package itself." Espanso's Two things are actually needed on Windows, and I've just pushed a commit (fe8c33f) documenting both in the package README:
The README's old "under WSL it works" line understated that, so it now carries the exact two-step recipe instead. Happy to adjust further if you'd prefer Windows handled differently. |
|
I'm not sure the addition of |
|
No rush at all — and the README already carries it as of fe8c33f (the "Windows (via WSL)" section documents both the |
| description: Type :tennis to expand a one-line summary of live tennis matches (via the Live Tennis API, free key required) | ||
| version: 0.1.0 | ||
| author: Live Tennis API | ||
| homepage: "https://livetennisapi.com" |
There was a problem hiding this comment.
This ought to link to a homepage of your own, although it's not critical.
|
|
||
| The pipeline assumes a POSIX shell, and espanso's default shell on Windows is | ||
| PowerShell — so out of the box the trigger does not work on Windows. Espanso | ||
| can route a shell variable through WSL, but `shell: wsl` is a Windows-only |
There was a problem hiding this comment.
I've checked on Linux, and the presence of shell: wsl has no ill effect. I suggest you add it to the code in package.yml, and amend the README.md accordingly.
| vars: | ||
| - name: live_scores | ||
| type: shell | ||
| params: |
There was a problem hiding this comment.
Add shell: wsl here.
See above.
…WSL on Windows Signed-off-by: Ben Abulafia <ben@synapsereality.io>
|
Good question — yes, it does, and I've pushed the change. The vars:
- name: live_scores
type: shell
params:
shell: bash
cmd: |
…On macOS/Linux Nothing else in the package changed. Thanks for the catch. |
|
As long as you've tested Would you like to amend the Otherwise we'll be good to merge. |
…ips in the package Signed-off-by: Ben Abulafia <ben@synapsereality.io>
|
Done — amended the README's Windows section. Since Confirmed |
What it does
Adds
live-tennis-scores(0.1.0): typing:tennisexpands to a compact one-line summary of the tennis matches live right now — up to 3 matches, player names + per-set games,*on the set in play:Keyed API — graceful when unset
Unlike
dadjoke/cht, the API behind this package needs a key (free tier: 30 req/min, 100 req/day at livetennisapi.com/subscribe/free — far more than a text-expansion trigger uses). Two things keep that from hurting users:Set LIVETENNIS_API_KEY — free key: livetennisapi.com/subscribe/free. It never fails silently.Live Tennis API error: unauthorized).The README documents the env-var setup for Linux and macOS (including the GUI-app
launchctl setenvcaveat).Transparency (for review)
The entire behavior is one readable pipeline in
package.yml— no scripts, no files touched, nothing downloaded and executed:curl -s -H "Authorization: Bearer $LIVETENNIS_API_KEY" "https://api.livetennisapi.com/api/public/v1/matches?status=live&limit=3"grep -okeeps only the playernamefields and per-setgamesarrays (plus anyerrorstring)awkprogram pairs them into6-4 3-2*linesOnly POSIX tools (
curl,grep,awk,sh) — nojqdependency, matching the sed/grep style of existing curl packages (no,jops). Tested on gawk, mawk and busybox awk against a canned fixture and against the real endpoint's 401 path; not tested on Windows (README says so, likedadjoke)..github/scripts/validatepasses locally on the package (0 errors).Disclosure
I maintain the API this package calls (Live Tennis API).
🤖 Generated with Claude Code