From c522ef24bddf37efb3e0271f104c9fe46c294a06 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 30 Dec 2024 09:03:50 +0100 Subject: [PATCH] improve formatting of cas-curl help --- bin/cas-curl | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/bin/cas-curl b/bin/cas-curl index 9f6edb87..45fa22dd 100755 --- a/bin/cas-curl +++ b/bin/cas-curl @@ -1,18 +1,5 @@ #!/bin/bash -if [ "$#" -eq 0 ] || [ "$1" == "help" ] || [ "$1" == "--help" ] || [ "$1" == "-h" ]; then - cat <> [parameters] - - commands: -EOF - # filters out help texts (marked with ## and following lines with #) from the commands itself - # (the '' makes sure that this line is not found, just the lines with actual help texts) - sed -n '/#''#/ {s/#''#//; p; :a; n; /^[[:space:]]*#/!b; s/^[[:space:]]*#//; p; ba}' $0 - exit -fi - if [ "$2" == "--show-password" ]; then HSADMINNG_CAS_SHOW_PASSWORD=yes shift @@ -64,8 +51,16 @@ EOF exit 1 fi -function casLogout() { - rm -f ~/.cas-login-tgt +function casCurlDocumentation() { + cat <> [parameters] + + commands: +EOF + # filters out help texts (containing double-# and following lines with leading single-#) from the commands itself + # (the '' makes sure that this line is not found, just the lines with actual help texts) + sed -n '/#''#/ {x; p; x; s/#''#//; p; :a; n; /^[[:space:]]*#/!b; s/^[[:space:]]*#//; p; ba}' <$0 } function casLogin() { @@ -107,6 +102,10 @@ function casLogin() { trace "$HSADMINNG_CAS_TGT" } +function casLogout() { + rm -f ~/.cas-login-tgt +} + function casTicket() { HSADMINNG_CAS_TGT=$(<~/.cas-login-tgt) if [[ -z "$HSADMINNG_CAS_TGT" ]]; then @@ -144,6 +143,11 @@ case "${1,,}" in # -- generic commands -------------------------------------------------------------------------- + ""|"-h"|"--help"|"help") ## prints documentation about commands and options + casCurlDocumentation + exit + ;; + "env") ## prints all related HSADMINNG_CAS_... environment variables; use '--show-password' to show the password as well # example: cas-curl env --show-password echo "HSADMINNG_CAS_LOGIN: $HSADMINNG_CAS_LOGIN"