Skip to content

Commit efd3e8f

Browse files
authored
cmd/jv: add -assertformat flag
1 parent 28c17b1 commit efd3e8f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ Prints:
184184
## CLI
185185

186186
```bash
187-
jv [-draft INT] [-output FORMAT] <json-schema> [<json-doc>]...
187+
jv [-draft INT] [-output FORMAT] [-assertformat] <json-schema> [<json-doc>]...
188+
-assertformat
189+
enable format assertions with draft >= 2019
188190
-draft int
189191
draft used when '$schema' attribute is missing. valid values 4, 5, 7, 2019, 2020 (default 2020)
190192
-output string

cmd/jv/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ import (
1111
)
1212

1313
func usage() {
14-
fmt.Fprintln(os.Stderr, "jv [-draft INT] [-output FORMAT] <json-schema> [<json-doc>]...")
14+
fmt.Fprintln(os.Stderr, "jv [-draft INT] [-output FORMAT] [-assertformat] <json-schema> [<json-doc>]...")
1515
flag.PrintDefaults()
1616
}
1717

1818
func main() {
1919
draft := flag.Int("draft", 2020, "draft used when '$schema' attribute is missing. valid values 4, 5, 7, 2019, 2020")
2020
output := flag.String("output", "", "output format. valid values flag, basic, detailed")
21+
assertFormat := flag.Bool("assertformat", false, "enable format assertions with draft >= 2019")
2122
flag.Usage = usage
2223
flag.Parse()
2324
if len(flag.Args()) == 0 {
@@ -42,6 +43,8 @@ func main() {
4243
os.Exit(1)
4344
}
4445

46+
compiler.AssertFormat = *assertFormat
47+
4548
var validOutput bool
4649
for _, out := range []string{"", "flag", "basic", "detailed"} {
4750
if *output == out {

0 commit comments

Comments
 (0)