Skip to content

feat: maptool doctor CLI command for toolchain diagnostics - #528

Merged
fank merged 1 commit into
mainfrom
feat/maptool-doctor
Jul 24, 2026
Merged

feat: maptool doctor CLI command for toolchain diagnostics#528
fank merged 1 commit into
mainfrom
feat/maptool-doctor

Conversation

@fank

@fank fank commented Jul 24, 2026

Copy link
Copy Markdown
Member

Instead of a static documentation file (previous approach in #461), provides a CLI command that both validates the map toolchain and gives users actionable install instructions.

Changes

New command: ocap-webserver maptool doctor

$ ocap-webserver maptool doctor
Map Toolchain — Diagnostics
════════════════════════════

Platform: Ubuntu 24.04.4 LTS
Distro:   ubuntu

Required Tools
──────────────
 ✗ pmtiles              not found (required)
 ✓ tippecanoe           /usr/bin/tippecanoe  tippecanoe v2.80.0 (required)

Recommended Tools
─────────────────
 ✓ gdal_translate       /usr/bin/gdal_translate
 ✗ gdal_calc.py         not found                       ⚠ Python bindings
 ...

Summary
═══════
   3 tools found, 7 tools missing
  Required readiness: 50% (RED)

Installation Instructions
═════════════════════════
...

What the doctor checks

  1. Detects all 10 external tools via exec.LookPath — pmtiles, tippecanoe, tile-join, 5 GDAL C++ tools, 2 GDAL Python scripts
  2. Probes versions where supported (--version on each found tool)
  3. Identifies known gotchas:
    • go-pmtiles installed instead of pmtiles (wrong binary name — the pipeline needs exactly pmtiles)
    • tippecanoe found but tile-join missing (partial install — they ship together)
    • GDAL Python scripts missing while GDAL C++ tools present (the separate-package gotcha documented in docs: manual install guide for the map toolchain #461)
  4. Auto-detects OS via runtime.GOOS + /etc/os-release (Debian, Ubuntu, Fedora, RHEL, Alpine, NixOS, macOS, Windows)
  5. Prints platform-specific install steps for the detected OS, falling back to showing all platforms for unknown distros
  6. Exits 0 when all required tools are found, exits 1 when any required is missing

Health levels

Level Meaning Exit
GREEN All tools found 0
YELLOW Required (pmtiles, tippecanoe) present, recommended missing 0
RED Required tools missing 1 + install guide printed

Files

File Purpose
internal/maptoolcli/doctor.go Core: diagnosis, reporting, OS detection, install instructions
internal/maptoolcli/doctor_test.go 35 tests covering all paths
internal/maptoolcli/maptool.go Registered doctor subcommand, updated usage
cmd/ocap-webserver/cli.go Updated root help

Closes #461 (supersedes the static docs approach)

Replaces the static docs/map-tools-installation.md approach (PR #461)
with a single diagnostic CLI command that detects all external tools,
identifies known gotchas (wrong binary name, missing Python bindings,
partial tippecanoe installs), and prints platform-specific install
instructions.

Commands:
  ocap-webserver maptool doctor   — diagnose + install guide

Key features:
- Auto-detects OS and prints per-platform install steps
- Probes tool versions via --version where available
- Detects cross-tool issues (Python bindings missing, binary name mismatches)
- Exits 0 only when all required tools (pmtiles, tippecanoe) are available
- Three health levels: GREEN / YELLOW / RED
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@github-actions

Copy link
Copy Markdown

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/cmd/ocap-webserver 27.45% (ø)
github.com/OCAP2/web/internal/maptoolcli 92.35% (+6.15%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/OCAP2/web/cmd/ocap-webserver/cli.go 100.00% (ø) 28 28 0
github.com/OCAP2/web/internal/maptoolcli/doctor.go 97.05% (+97.05%) 339 (+339) 329 (+329) 10 (+10) 🌟
github.com/OCAP2/web/internal/maptoolcli/maptool.go 97.19% (+0.11%) 178 (+7) 173 (+7) 5 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/OCAP2/web/internal/maptoolcli/doctor_test.go

@fank
fank merged commit 9708be3 into main Jul 24, 2026
2 checks passed
@fank
fank deleted the feat/maptool-doctor branch July 24, 2026 17:05
fank added a commit that referenced this pull request Jul 24, 2026
* feat: add maptool tools and install subcommands

Completes the original three-command proposal:
  ocap-webserver maptool tools    — compact status table
  ocap-webserver maptool doctor   — deep diagnostics (PR #528)
  ocap-webserver maptool install  — platform-specific install guide

maptool tools:
- Quick status table sorted: required first, then alphabetical
- Shows found/missing for all 10 tools with path and [required] tag
- Exits 0 if all required tools present, 1 otherwise

maptool install:
- Prints platform-specific install instructions (auto-detects OS)
- Reuses the install help infrastructure from doctor.go
- Always exits 0

* chore: register tools/install subcommands in dispatch and update usage
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