mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 22:55:06 +03:00
Always print valid config even if setting fails
This commit is contained in:
parent
7d4689cc12
commit
6d6544d180
1 changed files with 10 additions and 17 deletions
|
@ -121,8 +121,7 @@ func main() {
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
field := item.FieldByName(name)
|
field := item.FieldByName(name)
|
||||||
if !field.IsValid() {
|
if !field.IsValid() {
|
||||||
fmt.Println("Invalid option:", strings.Join(flags[1:len(flags)-1], " "))
|
break
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
switch field.Kind() {
|
switch field.Kind() {
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
|
@ -137,26 +136,20 @@ func main() {
|
||||||
if uint, uerr := strconv.ParseUint(value, 10, 64); uerr == nil {
|
if uint, uerr := strconv.ParseUint(value, 10, 64); uerr == nil {
|
||||||
field.SetUint(uint)
|
field.SetUint(uint)
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
fmt.Println("Invalid type for option:", name)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
intf := item.Interface().(map[string]interface{})
|
intf := item.Interface().(map[string]interface{})
|
||||||
intf[name] = value
|
intf[name] = value
|
||||||
}
|
}
|
||||||
var bs []byte
|
}
|
||||||
if *usejson {
|
var bs []byte
|
||||||
if bs, err = json.Marshal(cfg); err == nil {
|
if *usejson {
|
||||||
fmt.Println(string(bs))
|
if bs, err = json.Marshal(cfg); err == nil {
|
||||||
}
|
fmt.Println(string(bs))
|
||||||
} else {
|
}
|
||||||
if bs, err = hjson.Marshal(cfg); err == nil {
|
} else {
|
||||||
fmt.Println(string(bs))
|
if bs, err = hjson.Marshal(cfg); err == nil {
|
||||||
}
|
fmt.Println(string(bs))
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
|
||||||
default:
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue