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", Cfg.SQLite.Callsign) DeleteDatabase("./flex.sqlite", log) repo := NewFlexDXDatabase("flex.sqlite", log) TCPServer := NewTCPServer(Cfg.Telnet.Host, Cfg.Telnet.Port, log) FlexClient := NewFlexClient(*repo, *TCPServer, log) TCPClient := NewTCPClient(*Cfg, TCPServer, FlexClient, log) go FlexClient.StartFlexClient() go TCPClient.StartClient() go TCPServer.StartServer() select {} }