#!/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
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