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 5204d86 commit 40cc8ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Console.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (i *Input) ParsedOptions(Config Argument, args []string) {
// 支持多个默认值
for _, kv2 := range Config.Option {
if kv.Name == kv2.Name {
i.Option[kv.Name] = append(i.Option[kv.Name], kv.Default)
i.Option[kv.Name] = append(i.Option[kv.Name], kv2.Default)
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func main() {

app.AddBaseOption(command.ArgParam{
Name: "TEST",
Description: "fffffffffffffffffffffffff",
Description: "显示帮助信息",
Default: "false",
Call: nil,
})
Expand Down Expand Up @@ -55,7 +55,8 @@ func (Hello) Configure() command.Configure {
},
// 可选的参数,不输入也能执行
Option: []command.ArgParam{
{Name: "age", Description: "年龄选项参数"},
{Name: "age", Description: "年龄选项参数", Default: "18"},
{Name: "age", Description: "年龄选项参数", Default: "24"},
},
},
}
Expand Down

0 comments on commit 40cc8ba

Please sign in to comment.