40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
beerpongelo "git.kapelle.org/niklas/beerpong-elo/internal"
|
|
"github.com/alexflint/go-arg"
|
|
)
|
|
|
|
type args struct {
|
|
DBHost string `arg:"--db-endpoint,required,env:DB_HOST" help:"IP or hostname of the DB" placeholder:"DB_HOST"`
|
|
DBUsername string `arg:"--db-username,required,env:DB_USERNAME" help:"Username for the DB" placeholder:"DB_USERNAME"`
|
|
DBPassword string `arg:"--db-password,required,env:DB_PASSWORD" help:"Password for the DB" placeholder:"DB_PASSWORD"`
|
|
DBName string `arg:"--db-name,required,env:DB_NAME" help:"Name of the DB" placeholder:"DB_NAME"`
|
|
Address string `arg:"--address,env:ADDRESS" default:":3000" help:"What address to listen on" placeholder:"ADDRESS"`
|
|
Import string `arg:"--import" help:"Import a json file and exit" placeholder:"data.json"`
|
|
}
|
|
|
|
func (args) Version() string {
|
|
return "beerpong-elo v0.1"
|
|
}
|
|
|
|
func main() {
|
|
var args args
|
|
arg.MustParse(&args)
|
|
|
|
config := beerpongelo.Config{
|
|
DBHost: args.DBHost,
|
|
DBUsername: args.DBUsername,
|
|
DBPassword: args.DBPassword,
|
|
DBName: args.DBName,
|
|
Address: args.Address,
|
|
}
|
|
|
|
if args.Import != "" {
|
|
beerpongelo.Import(config,args.Import)
|
|
return
|
|
}
|
|
|
|
beerpongelo.Start(config)
|
|
}
|