add version flag

This commit is contained in:
Leo Antunes
2019-03-26 23:26:54 +01:00
parent e89a7141e5
commit 407bfbfb7e
3 changed files with 16 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package main // import "github.com/costela/wesher"
import (
"fmt"
"os"
"os/signal"
"syscall"
@ -10,11 +11,17 @@ import (
"github.com/costela/wesher/etchosts"
)
var version = "dev"
func main() {
config, err := loadConfig()
if err != nil {
logrus.Fatal(err)
}
if config.Version {
fmt.Println(version)
os.Exit(0)
}
logLevel, err := logrus.ParseLevel(config.LogLevel)
if err != nil {
logrus.Fatalf("could not parse loglevel: %s", err)