diff --git a/cmd/openttd_multitool/openttd_multitool.go b/cmd/openttd_multitool/openttd_multitool.go index 0fd536f..afcf436 100644 --- a/cmd/openttd_multitool/openttd_multitool.go +++ b/cmd/openttd_multitool/openttd_multitool.go @@ -1,10 +1,10 @@ package main import ( - "github.com/tardisx/openttd-admin/pkg/admin" - "flag" - "strings" - "os" + "flag" + "github.com/tardisx/openttd-admin/pkg/admin" + "os" + "strings" ) const currentVersion = "0.02" @@ -14,72 +14,72 @@ type monthlyFlags []string type yearlyFlags []string func (i *dailyFlags) String() string { - // change this, this is just can example to satisfy the interface - return "my string representation" + // change this, this is just can example to satisfy the interface + return "my string representation" } func (i *dailyFlags) Set(value string) error { - *i = append(*i, strings.TrimSpace(value)) - return nil + *i = append(*i, strings.TrimSpace(value)) + return nil } func (i *monthlyFlags) String() string { - // change this, this is just can example to satisfy the interface - return "my string representation" + // change this, this is just can example to satisfy the interface + return "my string representation" } func (i *monthlyFlags) Set(value string) error { - *i = append(*i, strings.TrimSpace(value)) - return nil + *i = append(*i, strings.TrimSpace(value)) + return nil } func (i *yearlyFlags) String() string { - // change this, this is just can example to satisfy the interface - return "my string representation" + // change this, this is just can example to satisfy the interface + return "my string representation" } func (i *yearlyFlags) Set(value string) error { - *i = append(*i, strings.TrimSpace(value)) - return nil + *i = append(*i, strings.TrimSpace(value)) + return nil } func main() { - var daily dailyFlags - var monthly monthlyFlags - var yearly yearlyFlags + var daily dailyFlags + var monthly monthlyFlags + var yearly yearlyFlags - flag.Var(&daily, "daily", "An RCON command to run daily - may be repeated") - flag.Var(&monthly, "monthly", "An RCON command to run monthly - may be repeated") - flag.Var(&yearly, "yearly", "An RCON command to run yearly - may be repeated") + flag.Var(&daily, "daily", "An RCON command to run daily - may be repeated") + flag.Var(&monthly, "monthly", "An RCON command to run monthly - may be repeated") + flag.Var(&yearly, "yearly", "An RCON command to run yearly - may be repeated") - var hostname string - var password string - var port int - flag.StringVar(&hostname, "hostname", "localhost", "The hostname (or IP address) of the OpenTTD server to connect to") - flag.StringVar(&password, "password", "", "The password for the admin interface ('admin_password' in openttd.cfg)") - flag.IntVar(&port, "port", 3977, "The port number of the admin interface (default is 3977)") - flag.Parse() + var hostname string + var password string + var port int + flag.StringVar(&hostname, "hostname", "localhost", "The hostname (or IP address) of the OpenTTD server to connect to") + flag.StringVar(&password, "password", "", "The password for the admin interface ('admin_password' in openttd.cfg)") + flag.IntVar(&port, "port", 3977, "The port number of the admin interface (default is 3977)") + flag.Parse() - if password == "" { - println("ERROR: You must supply a password") - os.Exit(1) - } - - server := admin.OpenTTDServer{} - - for _, value := range daily { - server.RegisterDateChange("daily", value) + if password == "" { + println("ERROR: You must supply a password") + os.Exit(1) } - for _, value := range monthly { - server.RegisterDateChange("monthly", value) - } + server := admin.OpenTTDServer{} - for _, value := range yearly { - server.RegisterDateChange("yearly", value) - } + for _, value := range daily { + server.RegisterDateChange("daily", value) + } - // this blocks forever - server.Connect(hostname, port, password, "openttd-multitool", currentVersion) + for _, value := range monthly { + server.RegisterDateChange("monthly", value) + } + + for _, value := range yearly { + server.RegisterDateChange("yearly", value) + } + + // this blocks forever + server.Connect(hostname, port, password, "openttd-multitool", currentVersion) }