Add gitfed-tui -create-repo for non-interactive repo creation
Same rationale as -set-public/-set-private: makes one operation scriptable over kubectl exec without driving the interactive TUI's keystrokes against a live instance. Verified end-to-end in a local sandbox: created a repo, confirmed it's reachable over the web, and pushed a real commit to it over SSH as the owner (implicit RoleAdmin via repo.Owner == principal, no separate ACL grant needed). Built as the backing piece for a "gitfed" Claude Code skill that publishes a local repo to a running instance end-to-end.
2 files changed
+34 −4
M
CHANGELOG.md
+4 −0
M
cmd/gitfed-tui/main.go
+30 −4
CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## 1.0.3
+
+- `gitfed-tui -create-repo <owner/repo> -owner <username> [-public]`: creates a repo non-interactively, same rationale as `-set-public`/`-set-private` — scriptable over `kubectl exec` without driving the TUI's keystrokes. Built for a Claude Code skill that publishes a local repo to a running instance end-to-end.
+
## 1.0.2
- The clone box now spans the full content width instead of stopping at 560px, matching the file list and every other card on the repo page.
cmd/gitfed-tui/main.go
@@ -23,6 +23,9 @@ func main() {
configPath := flag.String("config", "gitfed.json", "path to instance config file")
setPublic := flag.String("set-public", "", "non-interactive: make <repo> public and exit, skipping the TUI")
setPrivate := flag.String("set-private", "", "non-interactive: make <repo> private and exit, skipping the TUI")
+ createRepo := flag.String("create-repo", "", "non-interactive: create <owner/repo> and exit, skipping the TUI (requires -owner)")
+ createOwner := flag.String("owner", "", "local username that owns the repo created by -create-repo")
+ createPublic := flag.Bool("public", false, "with -create-repo, also make the new repo public")
flag.Parse()
cfg, err := config.Load(*configPath)
@@ -39,10 +42,10 @@ func main() {
}
defer closeFn()
- // -set-public/-set-private exist so this one operation is scriptable
- // (e.g. over `kubectl exec`) without driving the interactive TUI's
- // keystrokes against a live instance — every other admin action still
- // goes through the TUI on purpose.
+ // -set-public/-set-private/-create-repo exist so these operations are
+ // scriptable (e.g. over `kubectl exec`) without driving the interactive
+ // TUI's keystrokes against a live instance — every other admin action
+ // still goes through the TUI on purpose.
if *setPublic != "" || *setPrivate != "" {
if *setPublic != "" && *setPrivate != "" {
fmt.Fprintln(os.Stderr, "gitfed-tui: pass only one of -set-public / -set-private")
@@ -60,6 +63,29 @@ func main() {
return
}
+ if *createRepo != "" {
+ if *createOwner == "" {
+ fmt.Fprintln(os.Stderr, "gitfed-tui: -create-repo requires -owner <username>")
+ os.Exit(1)
+ }
+ if err := ops.CreateRepo(*createRepo, *createOwner); err != nil {
+ fmt.Fprintf(os.Stderr, "gitfed-tui: create-repo %s: %v\n", *createRepo, err)
+ os.Exit(1)
+ }
+ if *createPublic {
+ if err := ops.SetRepoPublic(*createRepo, true); err != nil {
+ fmt.Fprintf(os.Stderr, "gitfed-tui: create-repo %s: set public: %v\n", *createRepo, err)
+ os.Exit(1)
+ }
+ }
+ visibility := "private"
+ if *createPublic {
+ visibility = "public"
+ }
+ fmt.Printf("%s created (owner: %s, %s)\n", *createRepo, *createOwner, visibility)
+ return
+ }
+
p := tea.NewProgram(newModel(ops, cfg.Domain, mode), tea.WithAltScreen())
if _, err := p.Run(); err != nil {
fmt.Fprintf(os.Stderr, "gitfed-tui: %v\n", err)