M README.md => README.md +41 -42
@@ 5,48 5,47 @@ An unrefined cli time tracker.
## Usage
- Usage:
- trk
- shows a 'today' report
- trk <entry_name>
- starts a timer tracking a named entry
- trk <time_spent> <entry_name>
- adds a new entry manually, with the specified time spent
- e.g.: '40m', '2h', '1h20m', etc., with 'h' and 'm' being
- [h]ours and [m]inutes
- (you can even use [d]ays and [s]econds, but why should you? :)
- trk t
- terminates the current timer
-
- trk r
- trk r today | week | month | lastweek | lastmonth
- shows the current month report
- or a report of the time range specified:
- today, current week (starting from monday), current month, etc.
- trk m | mm
- shortcut to 'trk r month' or 'trk r lastmonth'
- trk w | ww
- shortcut to 'trk r week' or 'trk r lastweek'
- trk M | MM
- trk W | WW
- same as above, but also reports each day of the time range
- trk s <query>
- greps through all trkfiles and report the results
- useful if you want to know the total time spent on an entry
-
- trk l
- lists the trk files
- trk e [trk_file]
- edit the trk file directly, defaulting to today trkfile
- trk y
- sync: commits eventual changes and do a pull/push of the trk dir
- trk g git_args
- runs git with git_args in the trk dir
- trk env
- prints exports of trk vars,
- eval-uating this output is useful for testing
- trk help | h
- shows help
+ trk
+ shows a 'today' report
+ trk t <entry_name>
+ starts a timer tracking a named entry
+ trk t
+ terminates the current timer
+ trk <entry_name> <time_spent>
+ adds a new entry manually, with the specified time spent
+ e.g.: '40m', '2h', '1h20m', etc., with 'h' and 'm' being
+ [h]ours and [m]inutes
+ (you can even use [d]ays and [s]econds, but why should you? :)
+
+ trk r
+ trk r today | week | month | lastweek | lastmonth
+ shows the current month report
+ or a report of the time range specified:
+ today, current week (starting from monday), current month, etc.
+ trk m | mm
+ shortcut to 'trk r month' or 'trk r lastmonth'
+ trk w | ww
+ shortcut to 'trk r week' or 'trk r lastweek'
+ trk M | MM
+ trk W | WW
+ same as above, but also reports each day of the time range
+ trk s <query>
+ greps through all trkfiles and report the results
+ useful if you want to know the total time spent on an entry
+
+ trk l
+ lists the trk files
+ trk e [trk_file]
+ edit the trk file directly, defaulting to today trkfile
+ trk y
+ sync: commits eventual changes and do a pull/push of the trk dir
+ trk g git_args
+ runs git with git_args in the trk dir
+ trk env
+ prints exports of trk vars,
+ eval-uating this output is useful for testing
+ trk help | h
+ shows help
Options:
--help -h Print this help
M test => test +21 -21
@@ 61,43 61,43 @@ setUp() {
test_time_entry_regex_validation() {
logt TIME_STRING_VALIDATION
- $trk 1t testing
+ $trk testing 1t
assertFalse "[ $? -eq 0 ]"
- $trk f testing
+ $trk testing f
assertFalse "[ $? -eq 0 ]"
- $trk 1 testing
+ $trk testing 1
assertFalse "[ $? -eq 0 ]"
- $trk 10 testing
+ $trk testing 10
assertFalse "[ $? -eq 0 ]"
- $trk 100m testing
+ $trk testing 100m
assertTrue "[ $? -eq 0 ]"
- $trk 199h testing
+ $trk testing 199h
assertTrue "[ $? -eq 0 ]"
- $trk 1h testing
+ $trk testing 1h
assertTrue "[ $? -eq 0 ]"
- $trk 10h testing
+ $trk testing 10h
assertTrue "[ $? -eq 0 ]"
- $trk 20m testing
+ $trk testing 20m
assertTrue "[ $? -eq 0 ]"
}
test_start_a_timer() {
logt START_TIMER
- $trk testing
+ $trk t testing
assertTrue "test -f $trk_active_file"
assertTrue "cat $trk_active_file | grep testing"
}
test_stop_a_timer() {
logt STOP_TIMER
- $trk testing
+ $trk t testing
sleep 1
$trk t
assertTrue 'trk active file is not empty after a stop' \
"test -z \"`head -n1 $trk_active_file`\""
assertTrue "cat $trkfile | grep '[12]s'"
- $trk testing
+ $trk t testing
sleep 2
$trk t
assertTrue "cat $trkfile | grep '[34]s'"
@@ 105,18 105,18 @@ test_stop_a_timer() {
test_add_entry() {
logt ADD_ENTRY
- $trk 1h testing
+ $trk testing 1h
assertTrue "grep 'testing 1h' $trkfile >/dev/null"
- $trk 1h testing
+ $trk testing 1h
assertTrue "grep 'testing 2h' $trkfile >/dev/null"
- $trk 30m testing
+ $trk testing 30m
assertTrue "grep 'testing 2h30m' $trkfile >/dev/null"
}
test_report() {
logt REPORTS
- $trk 1h testing
+ $trk testing 1h
assertTrue "$trk | grep '1h spent on testing' >/dev/null"
assertFalse "$trk | grep 'active entry' >/dev/null"
@@ 131,14 131,14 @@ test_report() {
assertTrue "$trk r month | grep '7h spent on monthtesting' >/dev/null"
assertFalse "$trk | grep 'active entry' >/dev/null"
- $trk activetesting
+ $trk t activetesting
sleep 1
assertTrue "$trk | grep 'activetesting' >/dev/null"
assertTrue "$trk | grep 'active entry' >/dev/null"
}
test_trkfile_creation() {
- $trk testing
+ $trk t testing
assertFalse "trkfile is created empty on start timer!" "test -f $trkfile"
$trk
assertFalse "trkfile is created empty on today report!" "test -f $trkfile"
@@ 162,18 162,18 @@ test_git_initial_handling() {
cd -
logt "doing the first push"
- $trk 1h testing
+ $trk testing 1h
$trk g add -A
$trk g commit -m 'Init'
$trk g push -u origin master
logt "using autosync from now on"
- $trk 1h testing
+ $trk testing 1h
$trk y
logt "handling a new file"
tomorrow_trkfile="$trkdir/`date -d '1 day' +"$trkfile_date_format"`.log"
- echo '1h test' > $tomorrow_trkfile
+ echo 'test 1h' > $tomorrow_trkfile
$trk y
}
M trk => trk +13 -13
@@ 40,15 40,15 @@ help="
Usage:
trk
shows a 'today' report
- trk <entry_name>
+ trk t <entry_name>
starts a timer tracking a named entry
- trk <time_spent> <entry_name>
+ trk t
+ terminates the current timer
+ trk <entry_name> <time_spent>
adds a new entry manually, with the specified time spent
e.g.: '40m', '2h', '1h20m', etc., with 'h' and 'm' being
[h]ours and [m]inutes
(you can even use [d]ays and [s]econds, but why should you? :)
- trk t
- terminates the current timer
trk r
trk r today | week | month | lastweek | lastmonth
@@ 482,8 482,13 @@ if [ -z "$command" ]; then
echo "run [`basename $0` h] for help"
elif [ "$command" = "t" ]; then
- stop_timer
- show_report 'today'
+ entry_to_start="$2"
+ if test -z "$entry_to_start"; then
+ stop_timer
+ show_report 'today'
+ else
+ start_timer "$entry_to_start"
+ fi
elif [ "$command" = "l" ]; then
cd $trkdir
@@ 555,12 560,7 @@ elif [ "$command" = "--help" ] \
echo "$help"
else
tag="$command"
- if test -z "$2"; then
- start_timer "$tag"
- else
- time_spent="$command"
- tag="$2"
- add_entry "$tag" "$time_spent"
- fi
+ time_spent="$2"
+ add_entry "$tag" "$time_spent"
fi