Skip to content

Commit

Permalink
Added printing the go.mod version
Browse files Browse the repository at this point in the history
  • Loading branch information
takashabe committed May 19, 2019
1 parent cd0519b commit 32d65fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions cmd/btcli/btcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@ package main

import (
"os"
"runtime/debug"

"github.com/takashabe/btcli/pkg/cmd/interactive"
)

// App version
var (
Version = "undefined"
Revision = "undefined"
Version = "undefined"
Sum = "undefined"
)

func main() {
if i, ok := debug.ReadBuildInfo(); ok {
Version = i.Main.Version
Sum = i.Main.Sum
}

cli := &interactive.CLI{
OutStream: os.Stdout,
ErrStream: os.Stderr,
Version: Version,
Revision: Revision,
Sum: Sum,
}
os.Exit(cli.Run(os.Args))
}
6 changes: 3 additions & 3 deletions pkg/cmd/interactive/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ type CLI struct {
OutStream io.Writer
ErrStream io.Writer

Version string
Revision string
Version string
Sum string
}

// Run invokes the CLI with the given arguments
func (c *CLI) Run(args []string) int {
fmt.Fprintf(c.OutStream, "btcli Version: %s(%s)\n", c.Version, c.Revision)
fmt.Fprintf(c.OutStream, "btcli Version: %s(%s)\n", c.Version, c.Sum)
fmt.Fprintf(c.OutStream, "Please use `exit` or `Ctrl-D` to exit this program.\n")

conf, err := c.loadConfig(args)
Expand Down

0 comments on commit 32d65fb

Please sign in to comment.