forked from go/pgm
Audit with AI
This commit is contained in:
21
cmd/main.go
21
cmd/main.go
@@ -9,29 +9,42 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
const usageTxt = `Please provide output director and input schema.
|
||||
var (
|
||||
showVersion bool
|
||||
)
|
||||
|
||||
const usageTxt = `Please provide output directory and input schema.
|
||||
Example:
|
||||
pgm/cmd -o ./db ./db/schema.sql
|
||||
pgm -o ./db ./schema.sql
|
||||
|
||||
`
|
||||
|
||||
func main() {
|
||||
var outDir string
|
||||
flag.StringVar(&outDir, "o", "", "-o as output directory path")
|
||||
flag.BoolVar(&showVersion, "version", false, "show version information")
|
||||
flag.Parse()
|
||||
|
||||
// Handle version flag
|
||||
if showVersion {
|
||||
fmt.Printf("pgm %s\n", GetVersionString())
|
||||
fmt.Println("PostgreSQL Query Mapper - Schema code generator")
|
||||
fmt.Println("https://code.patial.tech/go/pgm")
|
||||
return
|
||||
}
|
||||
if len(os.Args) < 4 {
|
||||
fmt.Print(usageTxt)
|
||||
return
|
||||
}
|
||||
|
||||
if outDir == "" {
|
||||
println("missing, -o output directory path")
|
||||
fmt.Fprintln(os.Stderr, "Error: missing output directory path (-o flag required)")
|
||||
os.Exit(1)
|
||||
return
|
||||
}
|
||||
|
||||
if err := generate(os.Args[3], outDir); err != nil {
|
||||
println(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user