Skip to content

Commit 25140ab

Browse files
committed
Adding version commandline flag
1 parent c6784fe commit 25140ab

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

hover-ddns.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"flag"
5+
"fmt"
56
"io/ioutil"
67
"net"
78
"os"
@@ -21,15 +22,28 @@ type Config struct {
2122
PublicIPProvider publicip.LookupProviderConfig `yaml:"public_ip_provider"`
2223
}
2324

25+
var (
26+
version = "dev"
27+
commit = "none"
28+
date = "unknown"
29+
builtBy = "unknown"
30+
)
31+
2432
func main() {
2533
var verbose = flag.Bool("verbose", false, "Turns on verbose information on the update process. Otherwise, only errors cause output.")
2634
var debug = flag.Bool("debug", false, "Turns on debug information")
2735
var dryRun = flag.Bool("dry-run", false, "Perform lookups but don't actually update the DNS info")
2836
var configFile = flag.String("config", "", "Config file")
2937
var manualIPAddress = flag.String("ip-address", "", "Specify the IP address to be submitted instead of looking it up")
38+
var versionFlag = flag.Bool("version", false, "Prints version information of the hover-ddns binary")
3039

3140
flag.Parse()
3241

42+
if *versionFlag {
43+
fmt.Printf("hover-ddns version %s, commit %s, built at %s by %s\n", version, commit, date, builtBy)
44+
os.Exit(0)
45+
}
46+
3347
if *verbose {
3448
log.SetLevel(log.InfoLevel)
3549
} else if *debug {

0 commit comments

Comments
 (0)