diff sbin/check-ports @ 153:59a334dc9b53

Implement a usage message with the "-h" option
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 04 Nov 2019 09:30:05 +0100
parents 29e708b524e1
children 9b388927b12b
line wrap: on
line diff
--- a/sbin/check-ports	Sun Nov 03 19:44:43 2019 +0100
+++ b/sbin/check-ports	Mon Nov 04 09:30:05 2019 +0100
@@ -16,6 +16,31 @@
 
 VERSION='@@VERSION@@'
 
+USAGE='
+USAGE: check-ports [options] [args...]
+
+Options:
+
+  -V   Print the program name and version number to stdout and exit
+
+  -h   Print this help message to stdout and exit
+
+  -A   Print for every package the status of all repositories
+
+  -a   Print the data of all repos that have the package
+
+  -n   Print the status of given packages in `args` in all details.
+       No other options are respected.
+
+  -s   Print the status of all packages that need some attention
+
+  -v   Print the title and repository of every installed package always
+
+Per Default (without any option) the status of every package is
+printed with respect to repositories that have the package and have
+differing versions.
+'
+
 #
 # Configuration directory
 #
@@ -403,7 +428,7 @@
 }
 
 
-check_packages() {
+check_given_packages() {
     : 'Check the status of all given packages in the most detail possible
 
     Args:
@@ -464,12 +489,16 @@
 option_verbose=""
 option_packages=""
 
-while getopts "VAansv" _opt ; do
+while getopts "VhAansv" _opt ; do
     case ${_opt} in
 	V)
             printf 'check-ports v%s (rv:%s)\n' "${VERSION}" '@@HGREVISION@@'
             exit 0
 	    ;;
+        h)
+            echo "${USAGE}"
+            exit 0
+            ;;
         A)
             # Print for every package the status of all repositories
             option_alldata="1"
@@ -525,7 +554,7 @@
 fi
 
 if [ -n "${option_packages}" ]; then
-    check_packages "$@"
+    check_given_packages "$@"
 else
     check_ports
 fi