mirror of
https://github.com/itzg/mc-router.git
synced 2024-09-28 03:57:26 +02:00
Allow --mapping argument to be repeated or comma-separated
This commit is contained in:
parent
226f821598
commit
7779b866d1
@ -30,7 +30,7 @@ type MetricsBackendConfig struct {
|
||||
|
||||
type Config struct {
|
||||
Port int `default:"25565" usage:"The [port] bound to listen for Minecraft client connections"`
|
||||
Mapping string `usage:"Comma-separated mappings of externalHostname=host:port"`
|
||||
Mapping []string `usage:"Comma-separated or repeated mappings of externalHostname=host:port"`
|
||||
ApiBinding string `usage:"The [host:port] bound for servicing API requests"`
|
||||
Version bool `usage:"Output version and exit"`
|
||||
CpuProfile string `usage:"Enables CPU profiling and writes to given path"`
|
||||
@ -137,11 +137,9 @@ func main() {
|
||||
logrus.Info("Stopping")
|
||||
}
|
||||
|
||||
func parseMappings(val string) map[string]string {
|
||||
func parseMappings(vals []string) map[string]string {
|
||||
result := make(map[string]string)
|
||||
if val != "" {
|
||||
parts := strings.Split(val, ",")
|
||||
for _, part := range parts {
|
||||
for _, part := range vals {
|
||||
keyValue := strings.Split(part, "=")
|
||||
if len(keyValue) == 2 {
|
||||
result[keyValue[0]] = keyValue[1]
|
||||
@ -149,7 +147,6 @@ func parseMappings(val string) map[string]string {
|
||||
logrus.WithField("part", part).Fatal("Invalid part of mapping")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user