How neal-c/gh-ghpm works
Main Components
a. User & Environment
• Developer machine / terminal
• Installed GitHub CLI (gh) with the gh-ghpm extension
b. gh-ghpm CLI Extension (Go application)
• Entry point: main.go
• internal/cli package:
– root.go (command setup & flags)
– thanos_snap.go (batch-private logic)
– version.go (version command)
• Configuration: staticcheck.conf, go.mod/go.sum
c. GitHub API (external service)
• Repos list endpoint
• Edit repo endpoint
d. CI/CD Pipeline (GitHub Actions)
• .github/workflows/release.yaml for automated releases
Relationships & Data Flows
1. User runs “gh ghpm [command]” in terminal.
2. gh invokes the extension binary.
3. The Go binary parses flags/commands via internal/cli/root.go.
4. For “thanos_snap”, it:
a. Calls GitHub API to list all user repos.
b. Filters out forks and repos with ≥1 star.
c. Sends edit-visibility requests to GitHub API for each remaining repo.
5. Responses from GitHub API are handled and output printed to the terminal.
6. CI/CD workflow triggers on new tags or commits, builds the Go binary, and publishes releases.
Architectural Patterns & Principles
• Single-binary CLI tool with modular internal packages (separation of concerns).
• Command-based architecture (root command + subcommands).
• External HTTP API integration with rate-limiting considerations (O(n) requests).
• CI/CD for continuous delivery.
Technologies, Frameworks & Libraries
• Go standard library (flag parsing, net/http)
• GitHub CLI extension mechanism
• GitHub REST API v3
• GitHub Actions for CI/CD