Accept config file as argument

Signed-off-by: JimZAH <me@james.ac>
This commit is contained in:
JimZAH 2023-05-13 11:43:11 +01:00
parent f27700b1cb
commit d238f007b7

11
main.go
View File

@ -7,6 +7,7 @@ import (
"net/http"
"os"
"strconv"
"strings"
"sync"
"time"
@ -158,7 +159,15 @@ func scrape(config *Config, callback chan []Call) {
}
func main() {
cFile, err := os.ReadFile("./dvsmon.conf")
cFileL := "./dvsmon.conf"
if len(os.Args) > 2 {
if !strings.ContainsAny(os.Args[1], "\\!@#$%^&*():;'\"|<>?") {
cFileL = os.Args[1]
}
}
cFile, err := os.ReadFile(cFileL)
if err != nil {
fmt.Println("Can't open config file! Expecting .dvsmon.conf: ", err)
os.Exit(-1)