Rewrite in Go: static binaries, zero runtime dependencies
Some checks failed
Release / build (push) Failing after 21s
Some checks failed
Release / build (push) Failing after 21s
Replace Node.js + Python codebase with three Go binaries: - claude-statusline: CLI status bar for Claude Code - claude-fetcher: standalone cron job for API usage - claude-widget: system tray icon (fyne-io/systray + fogleman/gg) All CGO-free for trivial cross-compilation. Add nfpm .deb packaging with autostart and cron. CI pipeline produces Linux + Windows binaries, .deb, .tar.gz, and .zip release assets. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
55
cmd/fetcher/main.go
Normal file
55
cmd/fetcher/main.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.davoryn.de/calic/claude-statusline/internal/config"
|
||||
"git.davoryn.de/calic/claude-statusline/internal/fetcher"
|
||||
)
|
||||
|
||||
func main() {
|
||||
sessionKey := config.GetSessionKey()
|
||||
if sessionKey == "" {
|
||||
fmt.Fprintln(os.Stderr, "error: no session key (set CLAUDE_SESSION_KEY or write to "+config.SessionKeyPath()+")")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cfg := config.Load()
|
||||
data, orgID, err := fetcher.FetchUsage(sessionKey, cfg.OrgID)
|
||||
if err != nil {
|
||||
if data != nil {
|
||||
// Write error state to cache so statusline can display it
|
||||
_ = fetcher.WriteCache(data)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := fetcher.WriteCache(data); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error writing cache: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Persist discovered org ID
|
||||
if orgID != "" && orgID != cfg.OrgID {
|
||||
cfg.OrgID = orgID
|
||||
_ = config.Save(cfg)
|
||||
}
|
||||
|
||||
parsed := fetcher.ParseUsage(data)
|
||||
if parsed.FiveHourPct > 0 {
|
||||
fmt.Printf("5h: %d%%", parsed.FiveHourPct)
|
||||
if parsed.FiveHourResetsIn != "" {
|
||||
fmt.Printf(" (resets in %s)", parsed.FiveHourResetsIn)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
if parsed.SevenDayPct > 0 {
|
||||
fmt.Printf("7d: %d%%", parsed.SevenDayPct)
|
||||
if parsed.SevenDayResetsIn != "" {
|
||||
fmt.Printf(" (resets in %s)", parsed.SevenDayResetsIn)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user