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:
|
||||
field := item.FieldByName(name)
|
||||
if !field.IsValid() {
|
||||
fmt.Println("Invalid option:", strings.Join(flags[1:len(flags)-1], " "))
|
||||
os.Exit(1)
|
||||
break
|
||||
}
|
||||
switch field.Kind() {
|
||||
case reflect.String:
|
||||
|
@ -137,14 +136,12 @@ func main() {
|
|||
if uint, uerr := strconv.ParseUint(value, 10, 64); uerr == nil {
|
||||
field.SetUint(uint)
|
||||
}
|
||||
default:
|
||||
fmt.Println("Invalid type for option:", name)
|
||||
os.Exit(1)
|
||||
}
|
||||
case reflect.Map:
|
||||
intf := item.Interface().(map[string]interface{})
|
||||
intf[name] = value
|
||||
}
|
||||
}
|
||||
var bs []byte
|
||||
if *usejson {
|
||||
if bs, err = json.Marshal(cfg); err == nil {
|
||||
|
@ -155,8 +152,4 @@ func main() {
|
|||
fmt.Println(string(bs))
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
default:
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue