Skip to content

Commit

Permalink
feat: Show build version
Browse files Browse the repository at this point in the history
  • Loading branch information
rjshrjndrn committed Mar 13, 2024
1 parent fa52085 commit 6d2fd3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ release:
name: templater
builds:
- main: ./cmd/app
ldflags:
- -s -w -X main.appVersion={{.Version}}
brews:
- name: templater
repository:
Expand Down
10 changes: 10 additions & 0 deletions cmd/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6d2fd3b

Please sign in to comment.