Add support for automatic jet version update.

This commit is contained in:
go-jet 2023-07-20 13:18:35 +02:00
parent e31e30b7f7
commit b38b63d804
2 changed files with 8 additions and 3 deletions

View file

@ -1,5 +1,7 @@
package main package main
//go:generate sh -c "printf 'package main\n\nconst version = \"'%s'\"' $(git describe --tags --abbrev=0) > version.go"
import ( import (
"flag" "flag"
"fmt" "fmt"
@ -159,7 +161,7 @@ func main() {
} }
func usage() { func usage() {
fmt.Println("Jet generator 2.8.0") fmt.Println("Jet generator", version)
fmt.Println() fmt.Println()
fmt.Println("Usage:") fmt.Println("Usage:")
@ -176,14 +178,14 @@ func usage() {
} }
fmt.Println() fmt.Println()
fmt.Println(`Example command: fmt.Println(`Example commands:
$ jet -dsn=postgresql://jet:jet@localhost:5432/jetdb?sslmode=disable -schema=dvds -path=./gen $ jet -dsn=postgresql://jet:jet@localhost:5432/jetdb?sslmode=disable -schema=dvds -path=./gen
$ jet -dsn=postgres://jet:jet@localhost:26257/jetdb?sslmode=disable -schema=dvds -path=./gen #cockroachdb $ jet -dsn=postgres://jet:jet@localhost:26257/jetdb?sslmode=disable -schema=dvds -path=./gen #cockroachdb
$ jet -source=postgres -dsn="user=jet password=jet host=localhost port=5432 dbname=jetdb" -schema=dvds -path=./gen $ jet -source=postgres -dsn="user=jet password=jet host=localhost port=5432 dbname=jetdb" -schema=dvds -path=./gen
$ jet -source=mysql -host=localhost -port=3306 -user=jet -password=jet -dbname=jetdb -path=./gen $ jet -source=mysql -host=localhost -port=3306 -user=jet -password=jet -dbname=jetdb -path=./gen
$ jet -source=sqlite -dsn="file://path/to/sqlite/database/file" -path=./gen $ jet -source=sqlite -dsn="file://path/to/sqlite/database/file" -path=./gen
`) `)
} }
func printErrorAndExit(error string) { func printErrorAndExit(error string) {

3
cmd/jet/version.go Normal file
View file

@ -0,0 +1,3 @@
package main
const version = "v2.10.0"