summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-13 03:07:32 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-13 03:07:32 -0400
commitf2d85b6dd0f7c955ac857b10909e2b2c8bbf01f2 (patch)
tree96d615792ef5bf430d2f8d0915b1d12316494d76
parent67864b2568b0d51f3970470f3292c7bdfaf31bee (diff)
downloadgetwtxt-f2d85b6dd0f7c955ac857b10909e2b2c8bbf01f2.tar.gz
changing flags
-rw-r--r--init.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/init.go b/init.go
index a4790d5..33e7059 100644
--- a/init.go
+++ b/init.go
@@ -14,10 +14,8 @@ import (
 
 // command line flags
 var (
-	port          *int    = pflag.IntP("port", "p", 9001, "getwtxt will serve from this port")
-	logfile       *string = pflag.StringP("logfile", "l", "getwtxt.log", "File for logging output")
-	twtxtfile     *string = pflag.StringP("twtxtfile", "f", "/var/twtxt/twtxt.txt", "Registry file for getwtxt")
-	stdoutLogging *bool   = pflag.BoolP("stdout", "o", true, "Log to stdout rather than to a file")
+	flagVersion *bool = pflag.BoolP("version", "v", false, "Display version information, then exit")
+	flagHelp    *bool = pflag.BoolP("help", "h", false, "")
 )
 
 // config object
@@ -27,18 +25,26 @@ var confObj = &configuration{}
 var closelog = make(chan bool, 1)
 
 func init() {
+	checkFlags()
 	titleScreen()
 	initConfig()
 	initLogging()
 	watchForInterrupt()
 }
 
-func initConfig() {
-
+func checkFlags() {
 	pflag.Parse()
-	if err := viper.BindPFlags(pflag.CommandLine); err != nil {
-		log.Printf("%v\n", err)
+	if *flagVersion {
+		titleScreen()
+		os.Exit(0)
+	}
+	if *flagHelp {
+		fmt.Printf("\n\nplaceholder\n\n")
+		os.Exit(0)
 	}
+}
+
+func initConfig() {
 
 	viper.SetConfigName("getwtxt")
 	viper.AddConfigPath(".")