Skip to content

Commit e1e054e

Browse files
author
Oleg Sucharevich
committed
add ExactlyOne argument rule
1 parent fa0f8c1 commit e1e054e

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

build/cli-generator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
metadata:
22
name: cli-generator
33
description: Generate CLI entrypoints from spec file
4-
version: 0.18.0
4+
version: 0.19.0
55
maintainers:
66
- Oleg Sucharevich
77
loose: true

configs/templates/spec.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@
106106
"enum": [
107107
"any",
108108
"atLeastOne",
109-
"atLeastTwo"
109+
"atLeastTwo",
110+
"exactlyOne"
110111
]
111112
},
112113
"default": [

configs/templates/templates.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/generate/language/golang_utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ func golangRulesToArgsValidation(rule string) string {
5959
return "cobra.MinimumNArgs(1)"
6060
case spec.AtLeastTwo:
6161
return "cobra.MinimumNArgs(2)"
62+
case spec.ExactlyOne:
63+
return "cobra.ExactArgs(1)"
6264
}
6365
return res
6466
}

pkg/spec/spec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const (
6464
Any Rule = "any"
6565
AtLeastOne Rule = "atLeastOne"
6666
AtLeastTwo Rule = "atLeastTwo"
67+
ExactlyOne Rule = "exactlyOne"
6768
)
6869

6970
type Type string

0 commit comments

Comments
 (0)