-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
This issue is a feature request
Both Arg and Option don't support default value now. In order to do that, I can write something like below:
installCommand := cli.NewCommand("install", "Install a package").
WithOption(
cli.NewOption("retry", "maximal retry times (default: 3)").WithType(cli.TypeInt),
).
WithArg(
cli.NewArg("package", "package name").WithType(cli.TypeString),
).
WithAction(func(args []string, options map[string]string) int {
if _, ok := options["retry"]; !ok {
options["retry"] = "3"
}
// do something
})With WithDefault method, I can write the default value 3 for only one time and avert a conflict between the actual code and the doc.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels