From: Gustav Eek Date: Sun, 25 Oct 2020 09:53:30 +0000 (+0100) Subject: [event-participant] Add help and printing option X-Git-Url: https://git.g-eek.se/?a=commitdiff_plain;h=c21ca3f166e33b00c0d13f35f2e57c68b6019237;p=users%2Fgustav%2Fscripts.git [event-participant] Add help and printing option Add a printing option to print the full list if input is empty. Also add a help message. --- diff --git a/event-participant b/event-participant index a14e3aa..fccdd42 100755 --- a/event-participant +++ b/event-participant @@ -1,8 +1,29 @@ #!/usr/bin/env bash +HELP=" +Adds a particpant to an event. + + event-participant [--help] [FILE] + +Participant and date added are read from email on standard input. The +record is mantained in FILE. Most common is to leav FILE out, then the +formermost record is reused. + +If input is empty, also list of particiants is printed. + + echo | event-participant + +Help is this message. +" + CACHE="$HOME/.cache/${0##*/}/events.csv" HEADER="participant,date_att,date_cancel" +if [[ "$1" == "--help" ]]; then + echo -e "$HELP" 1>&2 + exit 0 +fi + arg_event="$1" if [ -f "$CACHE" ]; then @@ -43,3 +64,6 @@ n_t=$(cat "$event" | grep -v "$HEADER"| cut -d, -f2 | grep -v '^$' | wc -l) n_c=$(cat "$event" | grep -v "$HEADER"| cut -d, -f3 | grep -v '^$' | wc -l) n_p=$(( $n_t - $n_c )) echo -ne "At $event:\n part: $n_p\n canc: $n_c\n" 1>&2 +if [ -z "$info" ]; then + cat "$event" | tr ',' '\t' +fi