Skip to content

Commit

Permalink
feat: add version command (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwillker authored Dec 15, 2022
1 parent f860cea commit 23ec6e1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/osv-scanner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,23 @@ import (
"github.com/urfave/cli/v2"
)

var (
version = "dev"
commit = "n/a"
date = "n/a"
)

func run(args []string, stdout, stderr io.Writer) int {
var r *output.Reporter

cli.VersionPrinter = func(ctx *cli.Context) {
r = output.NewReporter(stdout, stderr, false)
r.PrintText(fmt.Sprintf("osv-scanner version: %s\ncommit: %s\nbuilt at: %s\n", ctx.App.Version, commit, date))
}

app := &cli.App{
Name: "osv-scanner",
Version: version,
Usage: "scans various mediums for dependencies and matches it against the OSV database",
Suggest: true,
Writer: stdout,
Expand Down

0 comments on commit 23ec6e1

Please sign in to comment.