Allow --mapping argument to be repeated or comma-separated
This commit is contained in:
@@ -30,7 +30,7 @@ type MetricsBackendConfig struct {
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Port int `default:"25565" usage:"The [port] bound to listen for Minecraft client connections"`
|
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"`
|
ApiBinding string `usage:"The [host:port] bound for servicing API requests"`
|
||||||
Version bool `usage:"Output version and exit"`
|
Version bool `usage:"Output version and exit"`
|
||||||
CpuProfile string `usage:"Enables CPU profiling and writes to given path"`
|
CpuProfile string `usage:"Enables CPU profiling and writes to given path"`
|
||||||
@@ -137,11 +137,9 @@ func main() {
|
|||||||
logrus.Info("Stopping")
|
logrus.Info("Stopping")
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseMappings(val string) map[string]string {
|
func parseMappings(vals []string) map[string]string {
|
||||||
result := make(map[string]string)
|
result := make(map[string]string)
|
||||||
if val != "" {
|
for _, part := range vals {
|
||||||
parts := strings.Split(val, ",")
|
|
||||||
for _, part := range parts {
|
|
||||||
keyValue := strings.Split(part, "=")
|
keyValue := strings.Split(part, "=")
|
||||||
if len(keyValue) == 2 {
|
if len(keyValue) == 2 {
|
||||||
result[keyValue[0]] = keyValue[1]
|
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")
|
logrus.WithField("part", part).Fatal("Invalid part of mapping")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user