package main import ( "flag" "log" "git.rouggy.com/rouggy/FlexDXCluster/logger" ) func ParseFlags() (string, error) { // String that contains the configured configuration path var configPath string // Set up a CLI flag called "-config" to allow users // to supply the configuration file flag.StringVar(&configPath, "config", "./config.yml", "path to config file") // Actually parse the flags flag.Parse() // Validate the path first if err := ValidateConfigPath(configPath); err != nil { return "", err } // Return the configuration path return configPath, nil } func main() { // Generate our config based on the config supplied // by the user in the flags cfgPath, err := ParseFlags() if err != nil { log.Fatal(err) } err = NewConfig(cfgPath) if err != nil { log.Fatal(err) } log := logger.NewLog() log.Info("config loaded.") log.Infof("Callsign: %s\n", Cfg.SQLite.Callsign) DeleteDatabase("./flex.sqlite", log) repo := NewFlexDXDatabase("flex.sqlite", log) // Create TelnetServer TCPServer := NewTCPServer(Cfg.Telnet.Host, Cfg.Telnet.Port, log) // Connect to Flex Radio (ip defined in config file) FlexClient := NewFlexClient(*repo, TCPServer, log) go FlexClient.StartFlexClient() // Connect to DX Cluster TelnetClient := TelnetClient{ Address: Cfg.Cluster.Server, Port: Cfg.Cluster.Port, Login: Cfg.Cluster.Login, MsgChan: TCPServer.MsgChan, CmdChan: TCPServer.CmdChan, SpotChan: FlexClient.SpotChan, Log: log, } go TelnetClient.StartClient() // Start TelnetServer go TCPServer.StartServer() select {} }