mirror of
https://tildegit.org/solderpunk/molly-brown.git
synced 2025-04-13 09:29:46 +00:00
Add -v flag to print version and exit. Closes #23.
This commit is contained in:
parent
d9e0fed193
commit
2d6f4db38e
1 changed files with 14 additions and 1 deletions
15
main.go
15
main.go
|
@ -3,17 +3,30 @@ package main
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var VERSION = "0.0.0"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var conf_file string
|
var conf_file string
|
||||||
|
var version bool
|
||||||
|
|
||||||
// Parse args and read config
|
// Parse args
|
||||||
flag.StringVar(&conf_file, "c", "", "Path to config file")
|
flag.StringVar(&conf_file, "c", "", "Path to config file")
|
||||||
|
flag.BoolVar(&version, "v", false, "Print version and exit")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
// If requested, print version and exit
|
||||||
|
if version {
|
||||||
|
fmt.Println("Molly Brown version", VERSION)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read config
|
||||||
if conf_file == "" {
|
if conf_file == "" {
|
||||||
_, err := os.Stat("/etc/molly.conf")
|
_, err := os.Stat("/etc/molly.conf")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue