Skip to content

Commit

Permalink
Expose version and commit information via the -v flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Homme Zwaagstra committed Nov 24, 2016
1 parent 953a1da commit ce400de
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ import (
"github.com/c9s/goprocinfo/linux"
)

// These get set on build.
var version, commit string

func init() {
if version == "" {
version = "No version information,"
}
if commit == "" {
commit = "unknown"
}
}

type SampleHandler func(metric float32, err error)

type Sampler interface {
Expand Down Expand Up @@ -311,12 +323,18 @@ func main() {
cin = flag.String("input", "", "file location to read commands from. Defaults to STDIN.")
cout = flag.String("stdout", "", "file location to send command standard output to. Defaults to STDOUT.")
cerr = flag.String("stderr", "", "file location to send command standard error to. Defaults to STDERR.")
v = flag.Bool("v", false, "print version information and exit.")
fout, ferr io.WriteCloser
fin io.Reader
)

flag.Parse()

if *v {
fmt.Printf("%s commit=%s\n", version, commit)
os.Exit(0)
}

if len(*cin) > 0 {
fh, err := os.Open(*cin)
if err != nil {
Expand Down

0 comments on commit ce400de

Please sign in to comment.