Skip to content

Commit

Permalink
Add version subcommand to the CLI. Fixes #184 (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
cvhariharan authored Oct 13, 2020
1 parent 5eed8d4 commit f5afd65
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/genji/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"runtime/debug"

"github.com/genjidb/genji/cmd/genji/shell"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -86,6 +87,27 @@ $ curl https://api.github.com/repos/genjidb/genji/issues | genji insert --db my.
return runInsertCommand(c.Context, engine, dbPath, table, c.Bool("auto"), args)
},
},
{
Name: "version",
Usage: "Shows Genji and Genji CLI version",
Action: func(c *cli.Context) error {
var cliVersion, genjiVersion string
info, ok := debug.ReadBuildInfo()
if ok {
cliVersion = info.Main.Version
}

for _, mod := range info.Deps {
if mod.Path != "github.com/genjidb/genji" {
continue
}
genjiVersion = mod.Version
break
}
fmt.Printf("Genji %v\nGenji CLI %v\n", genjiVersion, cliVersion)
return nil
},
},
}

// Root command
Expand Down

0 comments on commit f5afd65

Please sign in to comment.