Skip to content

Commit

Permalink
选项支持多个默认值
Browse files Browse the repository at this point in the history
  • Loading branch information
cyz-home committed Aug 16, 2024
1 parent d1a05af commit 5204d86
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Console.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,17 @@ func (i *Input) ParsedOptions(Config Argument, args []string) {
}
}
}
// 添加默认值
for _, kv := range Config.Option {
if len(i.Option[kv.Name]) == 0 {
i.Option[kv.Name] = append(i.Option[kv.Name], kv.Default)
// 支持多个默认值
for _, kv2 := range Config.Option {
if kv.Name == kv2.Name {
i.Option[kv.Name] = append(i.Option[kv.Name], kv.Default)
}
}
}
// 执行回调, 使用回调赋值
if kv.Call != nil {
var stop bool
i.Option[kv.Name][0], stop = kv.Call(i.Option[kv.Name][0], i.console)
Expand Down

0 comments on commit 5204d86

Please sign in to comment.