go fmt
This commit is contained in:
parent
e5d3f243fb
commit
5d3cbdd6b4
@ -1,10 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/tardisx/openttd-admin/pkg/admin"
|
"flag"
|
||||||
"flag"
|
"github.com/tardisx/openttd-admin/pkg/admin"
|
||||||
"strings"
|
"os"
|
||||||
"os"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const currentVersion = "0.02"
|
const currentVersion = "0.02"
|
||||||
@ -14,72 +14,72 @@ type monthlyFlags []string
|
|||||||
type yearlyFlags []string
|
type yearlyFlags []string
|
||||||
|
|
||||||
func (i *dailyFlags) String() string {
|
func (i *dailyFlags) String() string {
|
||||||
// change this, this is just can example to satisfy the interface
|
// change this, this is just can example to satisfy the interface
|
||||||
return "my string representation"
|
return "my string representation"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *dailyFlags) Set(value string) error {
|
func (i *dailyFlags) Set(value string) error {
|
||||||
*i = append(*i, strings.TrimSpace(value))
|
*i = append(*i, strings.TrimSpace(value))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *monthlyFlags) String() string {
|
func (i *monthlyFlags) String() string {
|
||||||
// change this, this is just can example to satisfy the interface
|
// change this, this is just can example to satisfy the interface
|
||||||
return "my string representation"
|
return "my string representation"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *monthlyFlags) Set(value string) error {
|
func (i *monthlyFlags) Set(value string) error {
|
||||||
*i = append(*i, strings.TrimSpace(value))
|
*i = append(*i, strings.TrimSpace(value))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *yearlyFlags) String() string {
|
func (i *yearlyFlags) String() string {
|
||||||
// change this, this is just can example to satisfy the interface
|
// change this, this is just can example to satisfy the interface
|
||||||
return "my string representation"
|
return "my string representation"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *yearlyFlags) Set(value string) error {
|
func (i *yearlyFlags) Set(value string) error {
|
||||||
*i = append(*i, strings.TrimSpace(value))
|
*i = append(*i, strings.TrimSpace(value))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
var daily dailyFlags
|
var daily dailyFlags
|
||||||
var monthly monthlyFlags
|
var monthly monthlyFlags
|
||||||
var yearly yearlyFlags
|
var yearly yearlyFlags
|
||||||
|
|
||||||
flag.Var(&daily, "daily", "An RCON command to run daily - 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(&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(&yearly, "yearly", "An RCON command to run yearly - may be repeated")
|
||||||
|
|
||||||
var hostname string
|
var hostname string
|
||||||
var password string
|
var password string
|
||||||
var port int
|
var port int
|
||||||
flag.StringVar(&hostname, "hostname", "localhost", "The hostname (or IP address) of the OpenTTD server to connect to")
|
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.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.IntVar(&port, "port", 3977, "The port number of the admin interface (default is 3977)")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if password == "" {
|
if password == "" {
|
||||||
println("ERROR: You must supply a password")
|
println("ERROR: You must supply a password")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
|
||||||
|
|
||||||
server := admin.OpenTTDServer{}
|
|
||||||
|
|
||||||
for _, value := range daily {
|
|
||||||
server.RegisterDateChange("daily", value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range monthly {
|
server := admin.OpenTTDServer{}
|
||||||
server.RegisterDateChange("monthly", value)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, value := range yearly {
|
for _, value := range daily {
|
||||||
server.RegisterDateChange("yearly", value)
|
server.RegisterDateChange("daily", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this blocks forever
|
for _, value := range monthly {
|
||||||
server.Connect(hostname, port, password, "openttd-multitool", currentVersion)
|
server.RegisterDateChange("monthly", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, value := range yearly {
|
||||||
|
server.RegisterDateChange("yearly", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// this blocks forever
|
||||||
|
server.Connect(hostname, port, password, "openttd-multitool", currentVersion)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user