1# SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 2#
 3# SPDX-License-Identifier: CC0-1.0
 4
 5GOOS := env("GOOS", `go env GOOS`)
 6GOARCH := env("GOARCH", `go env GOARCH`)
 7VERSION := `git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g'`
 8
 9default: fmt lint staticcheck test vuln reuse
10
11fmt:
12    # Formatting all Go source code
13    go install mvdan.cc/gofumpt@latest
14    gofumpt -l -w .
15
16lint:
17    # Linting Go source code
18    golangci-lint run
19
20staticcheck:
21    # Performing static analysis
22    go install honnef.co/go/tools/cmd/staticcheck@latest
23    staticcheck ./...
24
25test:
26    # Running tests
27    go test -v ./...
28
29vuln:
30    # Checking for vulnerabilities
31    go install golang.org/x/vuln/cmd/govulncheck@latest
32    govulncheck ./...
33
34reuse:
35    # Linting licenses and copyright headers
36    reuse lint
37
38docs:
39    # Generating CLI documentation (per-command and LLM reference)
40    go run ./internal/tools/docgen -out ./docs/cli -format markdown
41    go run ./internal/tools/docgen -out ./docs -format markdown -single llm-reference.md -exclude m
42
43build:
44    # Building nasin-pali
45    CGO_ENABLED=0 GOOS={{GOOS}} GOARCH={{GOARCH}} go build -o np -ldflags "-s -w -X main.version={{VERSION}}"
46
47run *FLAGS:
48    # Running np
49    CGO_ENABLED=0 GOOS={{GOOS}} GOARCH={{GOARCH}} go run -ldflags "-s -w -X main.version={{VERSION}}" . {{FLAGS}}
50
51pack:
52    # Packing np
53    upx --best -qo np.min np
54    mv np.min np
55
56clean:
57    # Removing build artifacts
58    rm -rf np
59
60clean-all:
61    # Removing build artifacts and config.toml
62    rm -rf np config.toml