Skip to content

Commit

Permalink
Add version.go
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed Jan 17, 2017
1 parent e24dc41 commit f9fb20a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
29 changes: 1 addition & 28 deletions main.go
@@ -1,35 +1,8 @@
package main // import "github.com/hashicorp/consul-replicate"

import (
"bytes"
"fmt"
"os"
)

// The git commit that was compiled. This will be filled in by the compiler.
var GitCommit string

const Name = "consul-replicate"
const Version = "0.2.1"
const VersionPrerelease = "dev"
import "os"

func main() {
cli := NewCLI(os.Stdout, os.Stderr)
os.Exit(cli.Run(os.Args))
}

// formattedVersion returns a formatted version string which includes the git
// commit and development information.
func formattedVersion() string {
var versionString bytes.Buffer
fmt.Fprintf(&versionString, "%s v%s", Name, Version)

if VersionPrerelease != "" {
fmt.Fprintf(&versionString, "-%s", VersionPrerelease)

if GitCommit != "" {
fmt.Fprintf(&versionString, " (%s)", GitCommit)
}
}
return versionString.String()
}
11 changes: 11 additions & 0 deletions version.go
@@ -0,0 +1,11 @@
package main

import "fmt"

var (
Name string
Version string
GitCommit string

humanVersion = fmt.Sprintf("%s v%s (%s)", Name, Version, GitCommit)
)

0 comments on commit f9fb20a

Please sign in to comment.