Skip to content

Commit

Permalink
Improve help text.
Browse files Browse the repository at this point in the history
  • Loading branch information
icemarkom committed Nov 27, 2021
1 parent 2bd707b commit 5e2efb5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ builds:
- -w
- -X main.version={{.Version}}
- -X main.gitCommit={{.ShortCommit}}
- -X main.binaryName={{.ProjectName}}
targets:
- linux_amd64
- linux_arm64
Expand Down
17 changes: 17 additions & 0 deletions main/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"flag"
"fmt"
)

func programVersion() {
fmt.Fprintf(flag.CommandLine.Output(), "Version: %s\n Commit: %s\n", version, gitCommit)
}

func programUsage() {
fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [flags] hostname.or.ip.address\n\nFlags:\n", binaryName)
flag.PrintDefaults()
fmt.Fprintln(flag.CommandLine.Output())
programVersion()
}
7 changes: 5 additions & 2 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import (
)

var (
cfg mffp.Config
version, gitCommit string
cfg mffp.Config
version = "development"
gitCommit = ""
binaryName = "mffprober"
)

func printVersion(v, g string) {
Expand All @@ -25,6 +27,7 @@ func init() {
v, e bool
h string
)
flag.Usage = func() { programUsage() }

flag.StringVar(&h, "host", "", "DEPRECATED: Specify host name/address after the flags.")
flag.DurationVar(&cfg.Interval, "interval", 10*time.Second, "Polling interval in seconds")
Expand Down

0 comments on commit 5e2efb5

Please sign in to comment.