initial working read only state

This commit is contained in:
2026-07-27 14:03:54 +02:00
commit b0ac2f3e9a
13 changed files with 2286 additions and 0 deletions

60
main.go Normal file
View File

@@ -0,0 +1,60 @@
package main
import (
"flag"
"fmt"
"os"
"strings"
"time"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
var (
repo = flag.String("repo", os.Getenv("GH_REPO"), "GitHub repository as owner/name (or GH_REPO)")
poll = flag.Duration("poll", 10*time.Second, "refresh interval")
showAll = flag.Bool("all", false, "show all open PRs, not only PRs authored by you")
limit = flag.Int("limit", 50, "maximum open PRs to load (1-100)")
endpoint = flag.String("endpoint", "https://api.github.com/graphql", "GitHub GraphQL endpoint")
)
flag.Parse()
parts := strings.Split(*repo, "/")
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
exitf("--repo owner/name (or GH_REPO) is required")
}
if *limit < 1 || *limit > 100 {
exitf("--limit must be between 1 and 100")
}
if *poll < 2*time.Second {
exitf("--poll must be at least 2s")
}
token, err := resolveToken(*endpoint)
if err != nil {
exitf("authenticate: %v", err)
}
client := NewGitHubClient(*endpoint, token)
app := NewApp(client, parts[0], parts[1], *showAll, *limit, *poll)
if _, err := tea.NewProgram(app, tea.WithAltScreen()).Run(); err != nil {
exitf("run TUI: %v", err)
}
}
func firstNonEmpty(values ...string) string {
for _, value := range values {
if value != "" {
return value
}
}
return ""
}
func exitf(format string, args ...any) {
fmt.Fprintf(os.Stderr, "gh-threads: "+format+"\n", args...)
os.Exit(1)
}
// Keep interface drift visible at compile time.
var _ GitHubService = (*GitHubClient)(nil)