Add negatable tag to set a bool to be negatable.

If negatable, add `--[no-]` prefix to help.
This commit is contained in:
Joe Schmitt
2021-02-18 10:55:55 -05:00
committed by Alec Thomas
parent 2a0d7af9c5
commit 2fdddc4f51
7 changed files with 34 additions and 5 deletions
+3
View File
@@ -29,6 +29,7 @@ func TestHelp(t *testing.T) {
Slice []string `help:"A slice of strings." placeholder:"STR"`
Map map[string]int `help:"A map of strings to ints."`
Required bool `required help:"A required flag."`
Sort bool `negatable help:"Is sortable or not."`
One struct {
Flag string `help:"Nested flag."`
@@ -75,6 +76,7 @@ Flags:
--slice=STR,... A slice of strings.
--map=KEY=VALUE;... A map of strings to ints.
--required A required flag.
--[no-]sort Is sortable or not.
Commands:
one --required
@@ -115,6 +117,7 @@ Flags:
--slice=STR,... A slice of strings.
--map=KEY=VALUE;... A map of strings to ints.
--required A required flag.
--[no-]sort Is sortable or not.
--flag=STRING Nested flag under two.
--required-two