From 46a3e6984a970478e5f3266ef4ff04ad66bdfd14 Mon Sep 17 00:00:00 2001
From: Alban Gebler <alban.gebler@idiv.de>
Date: Thu, 8 Feb 2024 12:41:20 +0100
Subject: [PATCH] help option -h|--help added

---
 pdfform.sh | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/pdfform.sh b/pdfform.sh
index 7b2746e..32111a3 100644
--- a/pdfform.sh
+++ b/pdfform.sh
@@ -10,14 +10,29 @@
 ## v3 24-01-15 alban: add acceptance for wildcard *
 ## v4 24-01-17 alban: add file type check
 ## v5 24-01-23 alban: add binary check
+## v6 24-02-08 alban: add direct help option call
 
 
 ##
 helptext () {
-    echo "\n   Use with one or more files (spaces in file name need quoting or escaping): \n     ${0##*/} Example_1.pdf \"Example 2.pdf\" Example\ 3.pdf \n \n   Can be used also with wildcard: \n     ${0##*/} More_Examples_*.pdf \n\n"   
+    echo "\
+    \n\
+    This bash script rewrites the already filled in text of PDF forms \n\
+    to keep text visible in some viewer's (e.g. okular from KDE) display mode: \n\
+       ${0##*/} PDF_1 [... PDF_n] \n\
+    or prints this help text again: \n\
+       ${0##*/} --help | -h \n\
+    \n\
+    Use with one or more files (spaces in file name need quoting or escaping): \n\
+       ${0##*/} Example_1.pdf \"Example 2.pdf\" Example\ 3.pdf \n\
+    \n\
+    Can be used also with wildcard: \n\
+       ${0##*/} More_Examples_*.pdf \n\
+    \n\
+    "   
 }
 
-## check for binaries needed
+## check for needed binaries
 ## give needed binaries as space-seperated entries in variable $progs2check
 ##
 progs2check="pdftk"
@@ -30,7 +45,11 @@ for prog in $progs2check; do
 done
 
 ## help request as parameter
-# TBD
+case "$1" in
+	-h|--help) 	helptext
+			exit 0
+	;;
+esac
 
 ## no parameter
 if [ -z "$1" ]; then
@@ -59,5 +78,3 @@ for param in $*; do
     echo "   Result:     ${newfilename}"
 done
 
-
-
-- 
GitLab