Add UK support to the CLI#5
Conversation
distance --country now accepts United Kingdom/Great Britain; geocode --country hint and README/skill docs cover GB and UK field appends. Fixes stale v1.9 base-URL reference in CLAUDE.md.
Great Britain (the island) is not the same as the UK, and accepting a single canonical name per country matches the USA/Canada convention.
GB/US/CA codes work as a geocode hint but distance only accepts full names, so documenting full names (USA, Canada, United Kingdom) makes every example work across both commands.
leenyburger
left a comment
There was a problem hiding this comment.
Summary
Clean, small, well-scoped PR. It adds "United Kingdom" as a third accepted value for the --country flag, documents UK-specific data-append fields, and fixes a stale v1.9 base-URL reference in CLAUDE.md. The core change — one case "united kingdom" arm in normalizeCountry — is correct and backed by three new test cases (full name, case-insensitive, and an invalid-GB-ignored case) that match the implementation. Nothing here looks risky.
Findings
1. Stale doc comment on appendCountry (medium — should fix)
internal/cli/distance.go:14-15 still reads:
// appendCountry appends the country to an address if it's not already present.
// Only accepts "USA" or "Canada" (case-insensitive). Other values are ignored.This now also accepts "United Kingdom". The PR updated the user-facing warning strings and README but missed this comment. One-line fix.
2. distance/distance-matrix flag help wasn't updated (low)
distance.go:77 and distance.go:142 still show Usage: "Country to append to addresses (e.g. Canada)", while the README now documents this flag as accepting USA, Canada, or United Kingdom, and geocode's help string was updated to list all three. The in-CLI --help for distance is now less informative than the docs. Worth aligning for consistency (e.g. "(e.g. USA, Canada, United Kingdom)").
3. Behavioral divergence between geocode and distance country handling (low — pre-existing, but this PR sharpens the mismatch)
The two commands treat --country differently:
geocodepasses the raw flag value straight to the API as acountryquery param (geocode.go:75), with no normalization or validation —--country GBor--country foois sent as-is.distance/distance-matrixrun the value throughnormalizeCountry, append it to the address text, and warn+ignore anything not in the allowed set.
So geocodio geocode … --country GB silently forwards GB, while geocodio distance … --country GB warns and drops it. The divergence is intentional (geocode's API accepts a hint; distance only takes free-form address strings), but this PR's new geocode usage string — "Country hint (e.g. USA, Canada, United Kingdom)" — now implies a curated set that geocode doesn't actually enforce. Not a blocker; just flagging that the help text suggests validation that only distance performs.
4. UK append-field names are unverified documentation claims (informational)
The README/SKILL.md list uk-westminster, uk-westminster-next, uk-devolved, uk-devolved-next, uk-local, uk-local-next. These are pass-through --fields values, so the CLI doesn't validate them — correctness depends entirely on those matching the live API field IDs. Worth a quick confirmation against the Geocodio v2 docs, but nothing the code can enforce.
Verification note
Build/tests were not run in this review (go was unavailable in the review environment). The test logic is simple enough to verify by inspection and is consistent with the implementation, but CI / a local make test should confirm the suite is green.
Bottom line: Approve-with-nits. Only finding #1 (the stale comment) is worth fixing before merge; the rest are minor consistency polish.
Stale comment and distance/distance-matrix --country usage strings still referenced only USA/Canada; align them with the United Kingdom support.
MiniCodeMonkey
left a comment
There was a problem hiding this comment.
Thanks for catching this and making the changes. Especially the v2 migration misses!
It all looks good! Only thing I would flag, is that I would strongly prefer if we removed client-side country validation.
We should be able to add support for new countries in the future without having to update the CLI to enable support.
On the server-side, we support a large array of country formats, e.g. "USA", "US", "United States", etc. so there's no need to normalize on the client-side either.
Per PR review: the Geocodio API accepts a wide range of country formats (USA, US, United States, etc.), so client-side validation and normalization were unnecessary and required a CLI change to support each new country. --country now passes its value through as-is to the API. Drops normalizeCountry, the allow-list, and the invalid-country warnings.
Adds UK enablement on top of the already-merged API v2 migration (#4). The v2 work handled the version/response-shape bump; this PR adds the UK-specific layer it didn't touch.
Closes ENG-1080
Changes
distance --countrynow acceptsunited kingdom/great britain(case-insensitive) → appends"United Kingdom". Follows the existing strict full-name convention, so two-lettergb/ukare ignored with a warning, just likeus/caare today. Both thedistanceanddistance-matrixwarning messages updated.geocode --countryusage text:(US or CA)→(e.g. US, CA, GB). No logic change — the flag is forwarded as the APIcountryhint, which already fuzzy-matches GB/UK server-side.README.md, bundledskills/geocodio/SKILL.md): document GB country usage and the UK field appends (uk-westminster(-next),uk-devolved(-next),uk-local(-next)). Also added the previously-missing--countryrow to the distance flags table.CLAUDE.md: fixed a stalev1.9base-URL reference left over from the v2 migration (nowv2).Tests
TestAppendCountry(incl.GBrejected, matching the strict convention).gofmtclean ·go build ./...·go test -race ./...all pass ·go vetclean.UK geocoding is gated server-side by the
access-gb-geocodingentitlement; this PR is purely the client-side UX/docs to make UK usable from the CLI.