feat: carlos binary scaffold with subcommand dispatch
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6 files changed,
+84
−0
.gitignore+3 −0Makefile+17 −0go.mod+3 −0internal/version/version.go+6 −0internal/version/version_test.go+9 −0main.go+46 −0
diff --git a/.gitignore b/.gitignore| new file mode 100644 |
| index 000000000..1155390de |
| --- /dev/null |
| +++ b/.gitignore |
| @@ -0,0 +1,3 @@ |
| +carlos |
| +*.tfstate* |
| +.terraform/ |
diff --git a/Makefile b/Makefile| new file mode 100644 |
| index 000000000..7e858f35a |
| --- /dev/null |
| +++ b/Makefile |
| @@ -0,0 +1,17 @@ |
| +SHA := $(shell git rev-parse --short HEAD 2>/dev/null || echo dev) |
| +LDFLAGS := -s -w -X github.com/carlosframework/platform/internal/version.Build=$(SHA) |
| +GOOS ?= |
| +GOARCH ?= |
| + |
| +.PHONY: test build fmt |
| + |
| +test: |
| + go vet ./... |
| + @fmt_out=$$(gofmt -l .); if [ -n "$$fmt_out" ]; then echo "gofmt needed:"; echo "$$fmt_out"; exit 1; fi |
| + go test ./... |
| + |
| +build: |
| + CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -o carlos . |
| + |
| +fmt: |
| + gofmt -w . |
diff --git a/go.mod b/go.mod| new file mode 100644 |
| index 000000000..98da7c3f5 |
| --- /dev/null |
| +++ b/go.mod |
| @@ -0,0 +1,3 @@ |
| +module github.com/carlosframework/platform |
| + |
| +go 1.26 |
diff --git a/internal/version/version.go b/internal/version/version.go| new file mode 100644 |
| index 000000000..63b7cccfe |
| --- /dev/null |
| +++ b/internal/version/version.go |
| @@ -0,0 +1,6 @@ |
| +// Package version carries the build identity stamped at link time. |
| +package version |
| + |
| +// Build is the git short sha of the release, or "dev" for local builds. |
| +// Set via -ldflags "-X github.com/carlosframework/platform/internal/version.Build=<sha>". |
| +var Build = "dev" |
diff --git a/internal/version/version_test.go b/internal/version/version_test.go| new file mode 100644 |
| index 000000000..d83f0ebd4 |
| --- /dev/null |
| +++ b/internal/version/version_test.go |
| @@ -0,0 +1,9 @@ |
| +package version |
| + |
| +import "testing" |
| + |
| +func TestBuildDefaultsToDev(t *testing.T) { |
| + if Build != "dev" { |
| + t.Fatalf("Build = %q, want dev", Build) |
| + } |
| +} |
diff --git a/main.go b/main.go| new file mode 100644 |
| index 000000000..db575cdf9 |
| --- /dev/null |
| +++ b/main.go |
| @@ -0,0 +1,46 @@ |
| +// carlos is the CARLOS platform binary: edge, host agent, and operator CLI |
| +// in one artifact, selected by subcommand. |
| +package main |
| + |
| +import ( |
| + "fmt" |
| + "log" |
| + "os" |
| + |
| + "github.com/carlosframework/platform/internal/version" |
| +) |
| + |
| +func main() { |
| + if len(os.Args) < 2 { |
| + usage() |
| + os.Exit(2) |
| + } |
| + cmd, args := os.Args[1], os.Args[2:] |
| + _ = args |
| + switch cmd { |
| + case "version": |
| + fmt.Printf("carlos %s\n", version.Build) |
| + case "edge", "agent", "add", "remove", "instances", |
| + "ship", "promote", "channels", "canary", |
| + "bootstrap", "ops", "vet": |
| + log.Fatalf("not implemented: %s", cmd) |
| + default: |
| + usage() |
| + os.Exit(2) |
| + } |
| +} |
| + |
| +func usage() { |
| + fmt.Fprintln(os.Stderr, `usage: carlos <command> |
| + |
| +commands: |
| + version print the build id |
| + edge run the mesh front door (router) |
| + agent run edge + activator + release adoption on this host |
| + add | remove | instances manage routes |
| + ship | promote | channels publish and promote releases |
| + canary ship this worktree to an ephemeral canary channel |
| + bootstrap prepare a host (units, dirs, user) |
| + ops litestream | restore-verify |
| + vet check an app release against the platform contract`) |
| +} |