Mercurial > getan
comparison contrib/wochenbericht @ 5:e7245c2127e5
Applied patch from Stephan Holl to show usage on '-h' of '--help'. Added check for existence of db file.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 31 Jul 2008 10:45:11 +0200 |
parents | 2b2f74f301db |
children | 4de86feae6ac |
comparison
equal
deleted
inserted
replaced
4:2b2f74f301db | 5:e7245c2127e5 |
---|---|
10 # week defaults to current week, database to time.db | 10 # week defaults to current week, database to time.db |
11 # | 11 # |
12 # This is Free Software in terms of GPLv3 or later. See | 12 # This is Free Software in terms of GPLv3 or later. See |
13 # LICENSE coming with getan for details. | 13 # LICENSE coming with getan for details. |
14 # | 14 # |
15 usage() { | |
16 cat <<EOF | |
17 usage: ./wochenbericht [<week of year>] [<getan database file>] | |
18 <week of year> defaults to current week | |
19 <getan database file> defaults to time.db | |
20 EOF | |
21 exit 1 | |
22 } | |
23 | |
24 if [ "$1" == "--help" -o "$1" == "-h" ]; then | |
25 usage | |
26 fi | |
27 | |
28 | |
15 if [[ "$1" -eq "" ]]; then | 29 if [[ "$1" -eq "" ]]; then |
16 WEEK=`date +'%W'` | 30 WEEK=`date +'%W'` |
17 # remove hash below if you want previous week | 31 # remove hash below if you want previous week |
18 #WEEK=`expr ${WEEK} '-' 1 '|' 52` | 32 #WEEK=`expr ${WEEK} '-' 1 '|' 52` |
19 else | 33 else |
20 WEEK=$1 | 34 WEEK=$1 |
21 fi | 35 fi |
22 | 36 |
23 TIME_DB=${2:-time.db} | 37 TIME_DB=${2:-time.db} |
38 | |
39 if [ ! -f ${TIME_DB} ]; then | |
40 echo "error: Database file ${TIME_DB} does not exist." | |
41 usage | |
42 fi | |
24 | 43 |
25 sqlite3 ${TIME_DB} " | 44 sqlite3 ${TIME_DB} " |
26 SELECT coalesce(description, 'Verschiedenes'), total FROM projects | 45 SELECT coalesce(description, 'Verschiedenes'), total FROM projects |
27 INNER JOIN ( | 46 INNER JOIN ( |
28 SELECT | 47 SELECT |