Skip to content

add Compiler Explorer commands: languages, compilers, libraries - #1

Open
tamnd wants to merge 1 commit into
mainfrom
feat/pr1-ce-api
Open

tamnd wants to merge 1 commit into
mainfrom
feat/pr1-ce-api

Conversation

@tamnd

@tamnd tamnd commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Implements compilerexplorer-cli (binary `ce`) browsing the Compiler Explorer (Godbolt) public API.

Commands

  • `languages` -- list all supported programming languages
  • `compilers [--lang LANG_ID]` -- list compilers, optionally filtered by language
  • `libraries ` -- list available libraries for a language
  • `compiler ` -- show one compiler by id
  • `version` -- print build version

Changes

  • `compilerexplorer/types.go` -- exported types with `rank`, snake_case json tags, and `table` tags for the renderer; wire types mirror Godbolt camelCase; conversion helpers assign rank, join extensions as `", "`-separated strings, prefer semver over raw version, pick last library version as latest
  • `compilerexplorer/compilerexplorer.go` -- pass rank to conversion helpers
  • `compilerexplorer/compilerexplorer_test.go` -- 12 tests covering field mapping, Accept header, filtered URL path, version fallback, nightly flag, library latest/empty-versions, 503 retry

Notes

Open JSON REST API at godbolt.org -- no auth, no rate limits.
Every request sends `Accept: application/json` (without it the server returns HTML).
Supports 50+ languages and hundreds of compilers.

Implements the compilerexplorer package with three methods: Languages,
Compilers (optionally filtered by language id), and Libraries. Wire types
mirror the Godbolt camelCase API; exported types use snake_case json tags
with rank fields for stable ordering and a table tag for the renderer.

Extensions join as ", "-separated strings. Compiler.Version prefers the
semver field and falls back to the raw version string. Library.LatestVersion
takes the last entry in the versions array (oldest-to-newest order).

Twelve tests cover field mapping, Accept header enforcement, URL-filtered
compilers, version fallback, nightly flag, library latest/empty-versions,
and 503 retry behaviour.
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