Skip to content

Commit b83dfc1

Browse files
committed
Add missing main entry point and fix gitignore
1 parent 954c6ac commit b83dfc1

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ go.work.sum
3030
# Editor/IDE
3131
# .idea/
3232
# .vscode/
33-
repokill
33+
/repokill
3434
.devenv/
3535

3636
# Devenv

cmd/repokill/main.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"flag"
6+
"fmt"
7+
"os"
8+
9+
tea "github.com/charmbracelet/bubbletea"
10+
"github.com/valerius21/repokill/internal/filter"
11+
"github.com/valerius21/repokill/internal/github"
12+
"github.com/valerius21/repokill/internal/tui"
13+
)
14+
15+
// Version is set at build time via ldflags.
16+
var Version = "dev"
17+
18+
func main() {
19+
org := flag.String("org", "", "List repos for an organization")
20+
public := flag.Bool("public", false, "Show only public repos")
21+
private := flag.Bool("private", false, "Show only private repos")
22+
archived := flag.Bool("archived", false, "Show only archived repos")
23+
forked := flag.Bool("forked", false, "Show only forks")
24+
version := flag.Bool("version", false, "Show version")
25+
flag.Parse()
26+
27+
if *version {
28+
fmt.Printf("repokill %s\n", Version)
29+
os.Exit(0)
30+
}
31+
32+
// Build filter options
33+
var filterOpts filter.FilterOptions
34+
if *public {
35+
filterOpts.Visibility = "public"
36+
} else if *private {
37+
filterOpts.Visibility = "private"
38+
}
39+
if *archived {
40+
trueVal := true
41+
filterOpts.Archived = &trueVal
42+
}
43+
if *forked {
44+
trueVal := true
45+
filterOpts.Forked = &trueVal
46+
}
47+
48+
// Default sort: by pushedAt ascending (oldest first)
49+
sortOpts := filter.SortOptions{
50+
Field: filter.SortByPushedAt,
51+
Order: filter.Ascending,
52+
}
53+
54+
// Create GitHub client
55+
client := github.NewClient(*org, nil)
56+
57+
// Check authentication
58+
if err := client.CheckAuth(context.Background()); err != nil {
59+
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
60+
os.Exit(1)
61+
}
62+
63+
// Run TUI
64+
model := tui.New(client, filterOpts, sortOpts)
65+
p := tea.NewProgram(model, tea.WithAltScreen())
66+
67+
if _, err := p.Run(); err != nil {
68+
fmt.Fprintf(os.Stderr, "Error running TUI: %v\n", err)
69+
os.Exit(1)
70+
}
71+
}

0 commit comments

Comments
 (0)