Skip to content

Commit 10e2d71

Browse files
authored
Makefile,cmd/aperture,.gitignore: fix builds (#3)
1 parent 7073264 commit 10e2d71

3 files changed

Lines changed: 47 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
aperture
2-
dist/
1+
.build/
32
*.test
43
*.out

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: build test clean install
22

33
build:
4-
go build -o aperture ./cmd/aperture
4+
go build -o .build/aperture ./cmd/aperture
55

66
test:
77
go test ./...
@@ -10,4 +10,4 @@ install:
1010
go install ./cmd/aperture
1111

1212
clean:
13-
rm -f aperture
13+
rm -rf .build/

cmd/aperture/main.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
"log/slog"
7+
"os"
8+
9+
tea "github.com/charmbracelet/bubbletea"
10+
"github.com/tailscale/aperture-cli/internal/profiles"
11+
"github.com/tailscale/aperture-cli/internal/tui"
12+
)
13+
14+
var (
15+
flagVersion = flag.Bool("version", false, "print version and exit")
16+
flagDebug = flag.Bool("debug", false, "print env vars set before launching agent")
17+
18+
buildCommit = "dev"
19+
buildDate = "unknown"
20+
)
21+
22+
func main() {
23+
flag.Parse()
24+
25+
if *flagVersion {
26+
fmt.Printf("%s %s\n", buildDate, buildCommit)
27+
os.Exit(0)
28+
}
29+
30+
settings, _ := profiles.LoadSettings()
31+
state, _ := profiles.LoadState()
32+
33+
// Use the first saved endpoint as the active host; fall back to the default.
34+
host := "http://ai"
35+
if len(settings.Endpoints) > 0 {
36+
host = settings.Endpoints[0].URL
37+
}
38+
39+
p := tea.NewProgram(tui.NewModel(host, settings, state, *flagDebug))
40+
if _, err := p.Run(); err != nil {
41+
slog.Error("launcher error", "err", err)
42+
os.Exit(1)
43+
}
44+
}

0 commit comments

Comments
 (0)