aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-10-24 13:26:44 -0200
committerSilvio Rhatto <rhatto@riseup.net>2014-10-24 13:26:44 -0200
commit9e8b0b1eb8bfc495d68207f0377d8491dfe33100 (patch)
tree93dd6cd442f77d9ae91dd7df22ba53e5cf939ec5
parent3a4a5e7c8cf53ea71d47e4b84cb11307873ab71c (diff)
downloadtimelog-9e8b0b1eb8bfc495d68207f0377d8491dfe33100.tar.gz
timelog-9e8b0b1eb8bfc495d68207f0377d8491dfe33100.tar.bz2
Restructuring to support a main menu
-rwxr-xr-xtimelog52
1 files changed, 33 insertions, 19 deletions
diff --git a/timelog b/timelog
index 5cb9c58..140cad2 100755
--- a/timelog
+++ b/timelog
@@ -15,23 +15,10 @@ CODEBASE="$HOME/code"
GROUP="$1"
ACTION="$2"
BASENAME="`basename $0`"
+EDITOR=${EDITOR:=vi}
-if [ -z "$GROUP" ]; then
- echo "Usage: $BASENAME <group> [edit]"
- exit 1
-fi
-
-if [ -z "$EDITOR" ]; then
- EDITOR="vi"
-fi
-
-if [ -d "$CODEBASE/$GROUP" ] && [ ! -d "$BASE/$GROUP" ]; then
- BASE="$CODEBASE"
-fi
-
-mkdir -p $BASE/$GROUP/worklog
-
-if [ ! -e "$BASE/$GROUP/worklog/projects" ]; then
+# 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
@@ -44,8 +31,35 @@ EOF
echo "First run, you should edit your project list..."
$EDITOR $BASE/$GROUP/worklog/projects
( cd $BASE/$GROUP/worklog && worklog )
-elif [ "$ACTION" == "edit" ]; then
- $EDITOR $BASE/$GROUP/worklog/projects
+}
+
+# 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
- ( cd $BASE/$GROUP/worklog && worklog )
+ timelog_menu
fi