wip
This commit is contained in:
43
sqlgen/main.go
Normal file
43
sqlgen/main.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package sqlgen
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
usage := func() {
|
||||
fmt.Fprintf(os.Stderr, `
|
||||
%s DRIVER DEFS_PATH OUTPUT_PATH
|
||||
|
||||
Drivers are one of: sqlite, postgres
|
||||
`,
|
||||
os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(os.Args) != 4 {
|
||||
usage()
|
||||
}
|
||||
|
||||
var (
|
||||
template string
|
||||
driver = os.Args[1]
|
||||
defsPath = os.Args[2]
|
||||
outputPath = os.Args[3]
|
||||
)
|
||||
|
||||
switch driver {
|
||||
case "sqlite":
|
||||
template = sqliteTemplate
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "Unknown driver: %s", driver)
|
||||
usage()
|
||||
}
|
||||
|
||||
err := render(template, defsPath, outputPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user