diff --git a/.goreleaser.yaml b/.goreleaser.yaml index ca6e271..2587cc1 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -6,6 +6,8 @@ release: name: templater builds: - main: ./cmd/app + ldflags: + - -s -w -X main.appVersion={{.Version}} brews: - name: templater repository: diff --git a/cmd/app/main.go b/cmd/app/main.go index ec129e6..21ee5b3 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -72,13 +72,23 @@ func processTemplate(inputPath, outputPath string, values map[string]interface{} return nil } +// Default version for dev builds +var appVersion = "dev" + func main() { var inputPath, outputPath, valuesPath string + var showVersion bool flag.StringVar(&inputPath, "i", "", "Path to input file or directory") flag.StringVar(&outputPath, "o", "", "Output directory or file path (optional)") flag.StringVar(&valuesPath, "f", "", "Path to values YAML file (optional)") + flag.BoolVar(&showVersion, "v", false, "Prints the version of the app and exits") flag.Parse() + if showVersion { + fmt.Println("App Version:", appVersion) + return + } + if inputPath == "" { fmt.Println("Input path is required.") os.Exit(1)