-
Notifications
You must be signed in to change notification settings - Fork 0
/
kit
executable file
·56 lines (47 loc) · 1.2 KB
/
kit
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# kit: wrapper for using multiple keepintouch files.
validArgs=("basedir" "types")
source loadconf "$HOME/.scott-script/kit" "config" validArgs[@]
filename="$basedir/keepintouch"
if [ "$1" == '-h' ] || [ "$1" == '--help' ] || [ "$1" == 'help' ]
then
echo "Usage: $(basename $0) [contact type] [keepintouch args]"
echo
echo 'If [contact type] matches a defined type from the config file,'
echo 'keepintouch is run against `keepintouch.TYPE.dat` instead of'
echo '`keepintouch.dat`. In either case, all subsequent args are'
echo 'passed to keepintouch unchanged.'
exit 0
fi
for filetype in "${types[@]}"
do
if [ "$1" == "$filetype" ]
then
filename="${filename}.${filetype}"
shift
break
fi
done
filename="${filename}.dat"
if [ "$1" == 'contact' ]
then
if [ "$(date --utc +%d)" != "$(date +%d)" ]
then
echo 'FIXME: UTC date is after midnight, due to bug recorded date will be wrong.'
fi
keepintouch "$filename" "$@"
else
output=$(keepintouch "$filename" "$@")
fi
if [ "$output" == '' ]
then
if [ "$1" == '' ]
then
echo 'No one to contact, you are caught up!'
elif [ "$1" == 'contact' ]
then
echo 'Contact status updated.'
fi
else
echo "$output"
fi