From 94db2ec3dee19efa7eb955156dae1969347594da Mon Sep 17 00:00:00 2001
From: Hector <hector@hjs.dev>
Date: Sun, 30 Jan 2022 19:01:42 +0000
Subject: [PATCH] update readme with new -h output & update dockerfile

---
 README.md      | 31 +++++++++++++++----------------
 docker/run.sh  |  6 +++---
 src/cfg/cfg.go | 24 ++++++++++++------------
 3 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/README.md b/README.md
index 02b3676..b0d806d 100644
--- a/README.md
+++ b/README.md
@@ -38,23 +38,22 @@ See the [releases page](https://gitlab.com/hectorjsmith/fail2ban-prometheus-expo
 **Usage**
 ```
 $ fail2ban-prometheus-exporter -h
+usage: exporter [<flags>]
 
-  -collector.textfile
-        enable the textfile collector
-  -collector.textfile.directory string
-        directory to read text files with metrics from
-  -port int
-        port to use for the metrics server (default 9191)
-  -socket string
-        path to the fail2ban server socket
-  -version
-        show version info and exit
-  -web.basic-auth.password string
-        password to use to protect endpoints with basic auth
-  -web.basic-auth.username string
-        username to use to protect endpoints with basic auth
-  -web.listen-address string
-        address to use for the metrics server (default "0.0.0.0")
+Flags:
+  -h, --help                Show context-sensitive help (also try --help-long and --help-man).
+      --version             show version info and exit
+      --port=9191           port to use for the metrics server
+      --web.listen-address="0.0.0.0"
+                            address to use for the metrics server
+      --socket=""           path to the fail2ban server socket
+      --collector.textfile  enable the textfile collector
+      --collector.textfile.directory=""
+                            directory to read text files with metrics from
+      --web.basic-auth.username=""
+                            username to use to protect endpoints with basic auth
+      --web.basic-auth.password=""
+                            password to use to protect endpoints with basic auth
 ```
 
 **Example**
diff --git a/docker/run.sh b/docker/run.sh
index f6bf771..36ade9e 100644
--- a/docker/run.sh
+++ b/docker/run.sh
@@ -15,6 +15,6 @@ fi
 # Start the exporter (use exec to support graceful shutdown)
 # Inspired by: https://akomljen.com/stopping-docker-containers-gracefully/
 exec /app/fail2ban-prometheus-exporter \
-    -socket "$socket_path" \
-    -collector.textfile=$textfile_enabled \
-    -collector.textfile.directory="$textfile_dir"
+    --socket "$socket_path" \
+    --collector.textfile=$textfile_enabled \
+    --collector.textfile.directory="$textfile_dir"
diff --git a/src/cfg/cfg.go b/src/cfg/cfg.go
index a07ee9f..c71b360 100644
--- a/src/cfg/cfg.go
+++ b/src/cfg/cfg.go
@@ -10,11 +10,11 @@ import (
 const (
 	minServerPort               = 1000
 	maxServerPort               = 65535
-	portEnvName                 = "F2B_WEB_PORT"
-	addressEnvName              = "F2B_WEB_LISTEN_ADDRESS"
 	socketEnvName               = "F2B_COLLECTOR_SOCKET"
 	fileCollectorEnabledEnvName = "F2B_COLLECTOR_TEXT"
 	fileCollectorPathEnvName    = "F2B_COLLECTOR_TEXT_PATH"
+	portEnvName                 = "F2B_WEB_PORT"
+	addressEnvName              = "F2B_WEB_LISTEN_ADDRESS"
 	basicAuthUserEnvName        = "F2B_WEB_BASICAUTH_USER"
 	basicAuthPassEnvName        = "F2B_WEB_BASICAUTH_PASS"
 )
@@ -45,16 +45,6 @@ func readParamsFromCli(settings *AppSettings) {
 		Flag("version", "show version info and exit").
 		Default("false").
 		Bool()
-	port := kingpin.
-		Flag("port", "port to use for the metrics server").
-		Default("9191").
-		Envar(portEnvName).
-		Int()
-	address := kingpin.
-		Flag("web.listen-address", "address to use for the metrics server").
-		Default("0.0.0.0").
-		Envar(addressEnvName).
-		String()
 	socketPath := kingpin.
 		Flag("socket", "path to the fail2ban server socket").
 		Default("").
@@ -70,6 +60,16 @@ func readParamsFromCli(settings *AppSettings) {
 		Default("").
 		Envar(fileCollectorPathEnvName).
 		String()
+	port := kingpin.
+		Flag("port", "port to use for the metrics server").
+		Default("9191").
+		Envar(portEnvName).
+		Int()
+	address := kingpin.
+		Flag("web.listen-address", "address to use for the metrics server").
+		Default("0.0.0.0").
+		Envar(addressEnvName).
+		String()
 	rawBasicAuthUsername := kingpin.
 		Flag("web.basic-auth.username", "username to use to protect endpoints with basic auth").
 		Default("").