aboutsummaryrefslogtreecommitdiff
path: root/timelog
blob: 140cad29f41a3ff8c3bc5fb10f3c4a91d1822d4b (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
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
57
58
59
60
61
62
63
64
65
#!/bin/bash
#
# Worklog wrapper
#
# Alternatives to current worklog backend:
#
# https://github.com/distilledhype/node-worklog
# https://github.com/snaptortoise/worklog
# https://github.com/tormaroe/worklog
# https://github.com/winged/worklog
# https://github.com/yaccz/worklog

BASE="$HOME/file"
CODEBASE="$HOME/code"
GROUP="$1"
ACTION="$2"
BASENAME="`basename $0`"
EDITOR=${EDITOR:=vi}

# Setup a new worklog configuration
function timelog_setup {
  cat > $BASE/$GROUP/worklog/projects <<EOF
# Worklog project file
# note that projects appear in Worklog in REVERSE order

#H:Hosting
#I:Infrastructure
#O:Organization
EOF

  echo "First run, you should edit your project list..."
  $EDITOR $BASE/$GROUP/worklog/projects
  ( cd $BASE/$GROUP/worklog && worklog )
}

# Loop over available worklogs
# TODO
function timelog_menu {
  echo "Usage: $BASENAME <group> [edit]"
  exit 1
}

# Run
function timelog_run {
  if [ -d "$CODEBASE/$GROUP" ] && [ ! -d "$BASE/$GROUP" ]; then
    BASE="$CODEBASE"
  fi

  mkdir -p $BASE/$GROUP/worklog

  if [ ! -e "$BASE/$GROUP/worklog/projects" ]; then
    timelog_setup
  elif [ "$ACTION" == "edit" ]; then
    $EDITOR $BASE/$GROUP/worklog/projects
  else
    ( cd $BASE/$GROUP/worklog && worklog )
  fi
}

# Main
if [ ! -z "$GROUP" ]; then
  timelog_run
else
  timelog_menu
fi