Skip to content

Commit 40cc8ba

Browse files
committed
选项支持多个默认值
1 parent 5204d86 commit 40cc8ba

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Console.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (i *Input) ParsedOptions(Config Argument, args []string) {
237237
// 支持多个默认值
238238
for _, kv2 := range Config.Option {
239239
if kv.Name == kv2.Name {
240-
i.Option[kv.Name] = append(i.Option[kv.Name], kv.Default)
240+
i.Option[kv.Name] = append(i.Option[kv.Name], kv2.Default)
241241
}
242242
}
243243
}

examples/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func main() {
1111

1212
app.AddBaseOption(command.ArgParam{
1313
Name: "TEST",
14-
Description: "fffffffffffffffffffffffff",
14+
Description: "显示帮助信息",
1515
Default: "false",
1616
Call: nil,
1717
})
@@ -55,7 +55,8 @@ func (Hello) Configure() command.Configure {
5555
},
5656
// 可选的参数,不输入也能执行
5757
Option: []command.ArgParam{
58-
{Name: "age", Description: "年龄选项参数"},
58+
{Name: "age", Description: "年龄选项参数", Default: "18"},
59+
{Name: "age", Description: "年龄选项参数", Default: "24"},
5960
},
6061
},
6162
}

0 commit comments

Comments
 (0)