Skip to content

Commit 1a17f53

Browse files
committed
Use standalone cmd/spec for check-spec recipe
1 parent b59631d commit 1a17f53

4 files changed

Lines changed: 14 additions & 12 deletions

File tree

cmd/spec/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"os"
6+
7+
"pkgstatsd/internal/apidoc"
8+
)
9+
10+
func main() {
11+
data, _ := json.MarshalIndent(apidoc.BuildSpec(true), "", " ")
12+
_, _ = os.Stdout.Write(data)
13+
}

internal/apidoc/handler.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package apidoc
22

33
import (
44
"encoding/json"
5-
"io"
65
"net/http"
76
)
87

@@ -27,8 +26,3 @@ func (h *Handler) HandleDocJSON(w http.ResponseWriter, _ *http.Request) {
2726
func (h *Handler) RegisterRoutes(mux *http.ServeMux) {
2827
mux.HandleFunc("GET /api/doc.json", h.HandleDocJSON)
2928
}
30-
31-
func PrintSpec(w io.Writer, includeInternal bool) {
32-
data, _ := json.MarshalIndent(BuildSpec(includeInternal), "", " ")
33-
_, _ = w.Write(data)
34-
}

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ check-spec:
6767
set -euo pipefail
6868
spec=$(mktemp --suffix=.json)
6969
trap 'rm -f "$spec"' EXIT
70-
go run -tags development . spec > "$spec"
70+
go run ./cmd/spec > "$spec"
7171
go run github.com/daveshanley/vacuum@latest lint -bx -r vacuum.conf.yaml "$spec"
7272

7373
# auto-format all code

main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ import (
2828
const defaultCacheMaxAge = 5 * time.Minute
2929

3030
func main() {
31-
if isDevelopment && len(os.Args) > 1 && os.Args[1] == "spec" {
32-
apidoc.PrintSpec(os.Stdout, true)
33-
return
34-
}
35-
3631
cfg, err := config.Load()
3732
if err != nil {
3833
slog.Error("failed to load config", "error", err)

0 commit comments

Comments
 (0)