- Go 91.2%
- Shell 8.8%
| cmd/openlens | ||
| internal | ||
| .env.example | ||
| .gitignore | ||
| go.mod | ||
| install.sh | ||
| LICENSE | ||
| README.md | ||
go-openlens-cli
OpenLens CLI written in Go on top of the beta REST API.
Docs used:
- Overview: https://openlens.com/docs/api
- OpenAPI reference: https://docs.openlens.com/api-reference/openapi.json
Build
go build -o openlens ./cmd/openlens
Install
From the repo host:
curl -fsSL 'http://bread49:3030/api/v1/repos/aman/go-openlens-cli/raw/install.sh?ref=main' | bash
The installer downloads the source archive, builds ./cmd/openlens, and installs the binary to ~/.local/bin/openlens.
Override the install directory or source ref when needed:
curl -fsSL 'http://bread49:3030/api/v1/repos/aman/go-openlens-cli/raw/install.sh?ref=main' \
| OPENLENS_CLI_INSTALL_DIR=/usr/local/bin OPENLENS_CLI_REF=main bash
Requirements: curl, tar, and Go.
For a private repo, pass the same auth to the script so it can download the source archive:
curl -fsSL -u "$GITEA_USER:$GITEA_TOKEN" \
'http://bread49:3030/api/v1/repos/aman/go-openlens-cli/raw/install.sh?ref=main' \
| OPENLENS_CLI_CURL_USER="$GITEA_USER:$GITEA_TOKEN" bash
In this sandbox, use a writable Go cache:
GOCACHE=/tmp/go-openlens-cli-gocache go test ./...
GOCACHE=/tmp/go-openlens-cli-gocache go build -o /tmp/openlens ./cmd/openlens
Configuration
Production defaults to:
OPENLENS_BASE_URL=https://openlens.com/api
OPENLENS_API_KEY=...
Development uses the ignored .env file:
DEV_OPENLENS_URL=https://openlens-dev.up.railway.app
DEV_OPENLENS_API_KEY=...
The CLI normalizes host-only URLs by appending /api, so both of these are valid:
openlens --base-url https://openlens.com/api limits
openlens --base-url https://openlens-dev.up.railway.app limits
Profile behavior:
--profile autoprefersOPENLENS_*, thenDEV_OPENLENS_*, then production base URL.--profile devrequiresDEV_OPENLENS_URLand usesDEV_OPENLENS_API_KEY.--profile produsesOPENLENS_BASE_URLorhttps://openlens.com/api, andOPENLENS_API_KEY.
OPENLENS_PROJECT_ID or global --project-id can provide a default project for project-scoped commands.
Commands
openlens --profile dev config
openlens --profile dev platforms
openlens --profile dev projects list
openlens --profile dev runs --project-id <project-id>
openlens --profile dev run start --project-id <project-id>
openlens --profile dev run status --project-id <project-id> --run-id <run-id>
openlens --profile dev visibility --project-id <project-id> --type overview
openlens --profile dev trends --project-id <project-id> --days 30 --compare
openlens --profile dev sources --project-id <project-id> --limit 20
openlens --profile dev report visibility --project-id <project-id> --run-id <run-id> --out report.pdf
openlens --profile dev onboard analyze --url https://example.com
Use raw for beta endpoints that do not have first-class commands yet:
openlens --profile dev raw --query projectId=<project-id> GET /visibility
Current Dev Smoke Test
The dev deployment is reachable at https://openlens-dev.up.railway.app/api, but the current .env API key returns:
openlens API returned HTTP 401: {"error":"Not authenticated"}
That matches the API docs' 401 behavior for missing, malformed, or revoked keys. Once a valid dev key is available, the same commands should exercise the real API without code changes.