Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version subcommand to the CLI. Fixes #184 #254

Merged
merged 5 commits into from
Oct 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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