diff --git a/.goreleaser.yml b/.goreleaser.yml index 31197ff..5ee0514 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -17,6 +17,7 @@ builds: ldflags: - -s -w - -X main.Version={{.Version}} + - -X main.TemplatesPath={{.TemplatesPath}} main: ./cmd/mcptools/main.go archives: diff --git a/Makefile b/Makefile index 3a9033e..9901b96 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ check-go: build: @echo "$(YELLOW)Building $(BINARY_NAME)...$(NC)" - go build -ldflags "-X main.Version=$(VERSION)" -o bin/$(BINARY_NAME) ./cmd/mcptools + go build -ldflags "-X main.Version=$(VERSION) -X main.TemplatesPath=$(HOME)/.mcpt/templates" -o bin/$(BINARY_NAME) ./cmd/mcptools install-templates: mkdir -p $(HOME)/.mcpt/templates diff --git a/cmd/mcptools/commands/new.go b/cmd/mcptools/commands/new.go index 557bca3..585372f 100644 --- a/cmd/mcptools/commands/new.go +++ b/cmd/mcptools/commands/new.go @@ -10,6 +10,8 @@ import ( "github.com/spf13/cobra" ) +var TemplatesPath string = os.Getenv("HOME") + "/.mcpt/templates" + // Constants for template options. const ( sdkTypeScript = "ts" @@ -268,6 +270,9 @@ func findTemplatesDir(sdk string) string { // User home directory filepath.Join(os.Getenv("HOME"), ".mcpt", "templates", sdk), + // TemplatesPath from env + TemplatesPath, + // Executable directory func() string { execPath, err := os.Executable() diff --git a/cmd/mcptools/main.go b/cmd/mcptools/main.go index 33669ca..2911755 100644 --- a/cmd/mcptools/main.go +++ b/cmd/mcptools/main.go @@ -12,11 +12,13 @@ import ( // version information placeholders. var ( - Version = "dev" + Version = "dev" + TemplatesPath = os.Getenv("HOME") + "/.mcpt/templates" ) func init() { commands.Version = Version + commands.TemplatesPath = TemplatesPath } func main() {