Add flag for passing config file

main
Jasper Bok 2023-08-24 21:21:52 +02:00
parent eb172097c4
commit 8826be4637
1 changed files with 18 additions and 1 deletions

19
main.go
View File

@ -2,18 +2,35 @@ package main
import (
"flag"
"fmt"
"net/http"
"os"
)
var BusClient *http.Client
var Quays []Quay = []Quay{}
var Quays []Quay
func main() {
var confFilename string
var port int
flag.StringVar(&confFilename, "c", "", "Path to the configuration file")
flag.IntVar(&port, "p", 4444, "The port to start the server on")
flag.Parse()
if confFilename == "" {
fmt.Printf("No configuation file provided. Provide the path to a configuration file with the -c flag.\n")
os.Exit(0)
}
conf, err := ReadConfigFromFile(confFilename)
if err != nil {
fmt.Printf("%v\n", err)
os.Exit(1)
}
Quays = conf.Quays
BusClient = &http.Client{}
serveHttp(port)
}