Skip to content

Commit

Permalink
feat(influx): add version to influx CLI
Browse files Browse the repository at this point in the history
closes: #14821
  • Loading branch information
jsteenb2 committed Jun 2, 2020
1 parent 19a2496 commit 81a0982
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ $(CMDS): $(SOURCES)
# Ease of use build for just the go binary
influxd: bin/$(GOOS)/influxd

influx: bin/$(GOOS)/influx

#
# Define targets for the web ui
#
Expand Down
22 changes: 21 additions & 1 deletion cmd/influx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"path/filepath"
"strings"
"sync"
"time"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/bolt"
Expand All @@ -27,6 +28,12 @@ import (

const maxTCPConnections = 10

var (
version = "dev"
commit = "none"
date = time.Now().UTC().Format(time.RFC3339)
)

func main() {
influxCmd := influxCmd()
if err := influxCmd.Execute(); err != nil {
Expand Down Expand Up @@ -218,10 +225,23 @@ func (b *cmdInfluxBuilder) cmd(childCmdFns ...func(f *globalFlags, opt genericCL

// completion command goes last, after the walk, so that all
// commands have every flag listed in the bash|zsh completions.
cmd.AddCommand(completionCmd(cmd))
cmd.AddCommand(
completionCmd(cmd),
cmdVersion(),
)
return cmd
}

func cmdVersion() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Print the influx CLI version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Influx CLI %s (git: %s) build_date: %s\n", version, commit, date)
},
}
}

func influxCmd(opts ...genericCLIOptFn) *cobra.Command {
builder := newInfluxCmdBuilder(opts...)
return builder.cmd(
Expand Down

0 comments on commit 81a0982

Please sign in to comment.