Permalink
Browse files

Setup TODO.CFG file with Auto Archive, Date On Add. Add-ons for AGE a…

…nd FORMAT_LIST
  • Loading branch information...
1 parent a0a7d07 commit b5bf7fb106f2d8109f94e0e16ff77f1c9b82f32c @steppsr committed Dec 30, 2011
Showing with 303 additions and 28 deletions.
  1. +15 −1 README.textile
  2. +26 −16 clock.tcl
  3. +235 −11 tl.tcl
  4. +27 −0 todo.cfg
View
@@ -36,7 +36,6 @@ h1. Command Shortcuts
*Windows*
The *t.bat* file is a Windows Batch file to create a shorter command to run the program. The batch calls the interpreter with the program file and any command line parameters passed in also. It could be renamed to something else if prefered.
-@echo off@
@tclsh tl.tcl %*@
*Mac OS X*
@@ -48,3 +47,18 @@ h1. TCL Intrepreter
Tested with ActiveState's TCL Interpreter, which is available for
Windows (x86), Windows (64-bit, x64), Mac OS X (10.5+, x86_64/x86), Linux (x86), Linux (x86_64), Mac OS X (Universal).
"http://www.activestate.com/activetcl/downloads":http://www.activestate.com/activetcl/downloads
+
+h1. Add-ons
+
+*clock.tcl*
+This addon file has the ability to clock-in/clock-out of tasks.
+The clock-in adds a timestamp to the task @in:2011-12-29T13:15:20@ in (_YYYY-MM-DD_ *T* _HH:MM:SS_) format.
+The clock-out removes any clock-in, calculates the elapsed time, and adds the elapsed time to the task @lap:01:15:25@ in (_HH:MM:SS_) format.
+
+*Actions*
+* curr | current
+* in
+* help
+* laps
+* out
+* shorthelp
View
@@ -52,8 +52,9 @@ proc show_usage { {action "help"} {show_oneline true} {exit_after true}} {
}
laps {
- puts { laps}
+ puts { laps [SOURCE]}
puts { Displays report of all tasks with lap:times}
+ puts { SOURCE can be any file in the todo.txt directory. If not specified, the todo.txt file is used.}
}
out {
@@ -207,7 +208,7 @@ proc time_to_seconds {x_time} {
proc replace_item {data itemno term} {
global todo_path_n_file
set loopcount 1
-
+
set fp [open $todo_path_n_file "w"]
foreach line $data {
if {$loopcount != 1} {
@@ -229,8 +230,8 @@ proc get_bare_task {line} {
set result $line
set clock_in [get_clock_in $line]
set lap_time [get_lap_time $line]
- regsub -all -- "in:$clock_in" $result "" result ;# strip out any clockins
- regsub -all -- "lap:$lap_time" $result "" result ;# strip out any laptimes
+ regsub -all -- " in:$clock_in" $result "" result ;# strip out any clockins
+ regsub -all -- " lap:$lap_time" $result "" result ;# strip out any laptimes
return $result
}
@@ -242,17 +243,17 @@ proc process_clock_outs {} {
# Since its recursive, we need to open and read in the file each time the proc is run.
global todo_path_n_file
- set file_data [read_datafile $todo_path_n_file]
- set data [split $file_data "\n"]
+ set temp_file_data [read_datafile $todo_path_n_file]
+ set temp_data [split $temp_file_data "\n"]
set loopcount 1
set found 0
- foreach line $data {
+ foreach line $temp_data {
# make sure item has clock in
- if {[has_clock_in $data $loopcount]} {
-
+ if {[has_clock_in $temp_data $loopcount]} {
+
incr found
# get the clock in timestamp
@@ -280,7 +281,7 @@ proc process_clock_outs {} {
set new_task [append $new_task $new_task " lap:" $lap_time]
# replace task
- replace_item $data $loopcount $new_task
+ replace_item $temp_data $loopcount $new_task
}
incr loopcount
}
@@ -290,6 +291,12 @@ proc process_clock_outs {} {
}
}
+proc refresh_data {path_n_file} {
+ set file_data [read_datafile $path_n_file]
+ set data [split $file_data "\n"]
+ return $data
+}
+
# =============================================================================
# ======================== MAIN LOOP ==========================================
# =============================================================================
@@ -311,11 +318,7 @@ set fn todo.txt ;# TODO - Allow for diff filename from command line argument
set dir [file dirname [info script]]
set todo_path_n_file [file join $dir $fn]
-# Get the data from the file
-set file_data [read_datafile $todo_path_n_file]
-
-# Process data file
-set data [split $file_data "\n"]
+set data [refresh_data $todo_path_n_file]
switch -exact -- $action {
@@ -328,6 +331,9 @@ switch -exact -- $action {
in {
# Appends timestamp to task as in:timestamp
# Will clock out any other tasks that are currently clocked in
+ process_clock_outs
+ set data [refresh_data $todo_path_n_file]
+
if {![has_clock_in $data [lindex $terms 0]]} {
set sys_time [clock seconds]
set in_time [clock format $sys_time -format %Y-%m-%dT%H:%M:%S]
@@ -346,7 +352,11 @@ switch -exact -- $action {
laps {
# Displays report of all tasks with lap:times
- puts [eval exec [auto_execok $tcl_interpreter] tl.tcl ls lap:]
+ set filename [lindex $terms 0]
+ if {![file exists $filename]} {
+ set filename $fn
+ }
+ puts [eval exec [auto_execok $tcl_interpreter] tl.tcl lf $filename lap:]
}
out {
Oops, something went wrong.

0 comments on commit b5bf7fb

Please sign in to comment.