diff options
author | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2022-05-05 14:36:31 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2022-05-05 14:36:31 +0200 |
commit | e740d60265adacfef6edb6b534ae31eedf9011da (patch) | |
tree | f5447cd9f77bdf7ee607c29118df036aaac95a2a | |
parent | 9288d79ea1cfe2e9b2c9318f6f8cefe922bf1652 (diff) |
improved actions script with help command
-rwxr-xr-x | actions.sh | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -2,19 +2,25 @@ set -euC +help_text= + +help_text="$help_text run_tests\t[arg]\tpasses arg to the 'prove' tool\n" run_tests () { eval "prove -l ${1-} t/" } +help_text="$help_text start_dev\t[]\tstarts a hot reloading dev server\n" start_dev () { morbo script/jwebmail } +help_text="$help_text logrotate\t[mode]\tarives the current log file\n" logrotate () { mode=${1:-development} mv -i "log/$mode.log" "log/${mode}_$(date --iso-8601=minutes).log" } +help_text="$help_text linelength\t[files]\tchecks documentation files for overly long lines\n" linelength () { files=${1:-'README.md CHANGES.md LICENSE'} for file in $files @@ -23,17 +29,35 @@ linelength () { done } +help_text="$help_text follow\t[mode]\tfollows the current log file\n" follow () { mode=${1:-development} tail -f "log/$mode.log" } +help_text="$help_text check_manifest\t[]\tchecks if files in the MANIFEST actually exist\n" check_manifest () { perl -nE 'chomp; say unless -e' MANIFEST } -cmd=$1 -shift +help () { + echo "The following actions are available:" + echo + help_text="$(printf "$help_text")" # expand escapes in string + IFS=' +' # newline char + for var in $help_text + do + IFS="$(printf '\t')" + printf "%-17s %-8s %s\n" $var # expand var + done + echo +} + +if [ $# -gt 0 ] +then cmd=$1; shift +else cmd=help +fi if [ "$(command -v "$cmd")" = "$cmd" ] then eval "$cmd" "$@" else echo "unkown commad '$cmd'"; exit 1 |