summaryrefslogtreecommitdiff
path: root/tests/_setup_alias
blob: 0f2c6de1bf5e9b9f7d8e4635eab81a442a64ab4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
set -o pipefail
outfile=$(mktemp)

error() {
    echo "FAILURE"
    echo "$1"
    echo "sleeping 3"
    sleep 3
    exit 255
}

[ -z "$calendar_cli" ] && [ -x ./calendar-cli.py ] && calendar_cli=./calendar-cli.py
[ -z "$calendar_cli" ] && [ -x ../calendar-cli.py ] && calendar_cli=../calendar-cli.py
[ -z "$calendar_cli" ] && error "couldn't find ./calendar_cli.py nor ../calendar_cli.py"

[ -z "$kal" ] && [ -x ./cal.py ] && kal=./cal.py
[ -z "$kal" ] && [ -x ../cal.py ] && kal=../cal.py
[ -z "$kal" ] && error "couldn't find ./cal.py nor ../cal.py"

calendar_cli() {
    echo "    $calendar_cli $@"
    output=$($calendar_cli "$@" | tee $outfile)
    [ -z "$output" ] || [ -z "$QUIET" ] || echo $output
}

kal() {
    echo "    $kal $@"
    output=$($kal "$@"  | tee $outfile)
    [ -z "$output" ] || [ -z "$QUIET" ] || echo $output
}