Skip to content

Commit

Permalink
jv: add -v flag
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-tekuri committed May 3, 2024
1 parent 1de8a64 commit 625abe4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/jv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime/debug"
"slices"

"github.com/santhosh-tekuri/jsonschema/v6"
Expand All @@ -20,6 +21,7 @@ func main() {
flag.PrintDefaults()
}
help := flag.Bool("h", false, "Print help information")
version := flag.Bool("v", false, "Print build information")
quiet := flag.Bool("q", false, "Do not print errors")
draftVersion := flag.Int("d", 2020, "Draft `version` used when '$schema' is missing. Valid values 4, 6, 7, 2019, 2020")
output := flag.String("o", "simple", "Output `format`. Valid values simple, alt, flag, basic, detailed")
Expand All @@ -35,6 +37,19 @@ func main() {
os.Exit(0)
}

if *version {
bi, ok := debug.ReadBuildInfo()
if ok {
fmt.Println(bi.Main.Path, bi.Main.Version)
for _, dep := range bi.Deps {
fmt.Println(dep.Path, dep.Version)
}
} else {
fmt.Println("no build information available")
}
os.Exit(0)
}

// draft --
var draft *jsonschema.Draft
switch *draftVersion {
Expand Down

0 comments on commit 625abe4

Please sign in to comment.