aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/task/context
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2023-04-10 14:05:46 +0800
committerHsieh Chin Fan <pham@topo.tw>2023-04-10 14:05:46 +0800
commit91dd04beb19dc3d141c4743ce85579e7d6c29855 (patch)
tree7d3b832173190b92cf2e04b4adc435bb6b397378 /bin/task/context
parent280a1a84e4ebcf38ee24ef052e483afdc7c51d72 (diff)
Refactor context
Diffstat (limited to 'bin/task/context')
-rwxr-xr-xbin/task/context16
1 files changed, 12 insertions, 4 deletions
diff --git a/bin/task/context b/bin/task/context
index d0bb6c4..431b6ad 100755
--- a/bin/task/context
+++ b/bin/task/context
@@ -36,8 +36,8 @@ _set_context_plan() {
36 done <~/log/plan.context.md 36 done <~/log/plan.context.md
37} 37}
38 38
39# Update time of current context 39# Update spend time on current context
40if [ -n "$1" ]; then 40_update_spend_time() {
41 # If current conetxt is not given, exit with 1 41 # If current conetxt is not given, exit with 1
42 if [ -z "$context" ] || [ "$context" = none ]; then 42 if [ -z "$context" ] || [ "$context" = none ]; then
43 exit 1 43 exit 1
@@ -56,8 +56,10 @@ if [ -n "$1" ]; then
56 56
57 # Update Log file 57 # Update Log file
58 echo -e "$context\t${given_seconds}" >>$LOG_FILE 58 echo -e "$context\t${given_seconds}" >>$LOG_FILE
59# Print times for each context 59}
60else 60
61# Print spend for each context
62_print_spend_time() {
61 _set_context_plan 63 _set_context_plan
62 while read -r ctx sec; do 64 while read -r ctx sec; do
63 # Print context and time I spend 65 # Print context and time I spend
@@ -90,4 +92,10 @@ else
90 fi 92 fi
91 echo 93 echo
92 done <$LOG_FILE 94 done <$LOG_FILE
95}
96
97if [ -n "$1" ]; then
98 _update_spend_time
99else
100 _print_spend_time
93fi 101fi