Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit e262520

Browse files
committed
Ask for an end time when stoping a timer
1 parent 77e830b commit e262520

File tree

4 files changed

+253
-90
lines changed

4 files changed

+253
-90
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The source code is available at [Github][gh]. Pull requests are welcome.
2929
Clone this repository.
3030
Copy the `info.plist.template` file to `info.plist`.
3131

32-
The update the variables `hakuna_api_key` and `hakuna_base_url` to match your Hakuna instance.
32+
Then update the variables `hakuna_api_key` and `hakuna_base_url` to match your Hakuna instance.
3333

3434
**Before you push, make sure to copy `info.plist` to `info.plist.template` and remove all sensitive information!**
3535

action_start_timer.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ project_id=${hakuna_project_id-$1}
1919
task_id=${hakuna_task_id-$2}
2020
if ! start_time=$(format_time "${start_time-$3}"); then
2121
echo "The given time '$start_time' is not valid. The expected format is 'hh:mm' or 'hh:mm:ss'."
22+
exit 1
2223
fi
2324
note=${hakuna_note-${4-}}
2425

action_stop_timer.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,29 @@
22

33
. utils.sh
44

5-
load timer PUT
5+
format_time() {
6+
if expr "$1" : '^[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$' > /dev/null; then
7+
echo "${1%:*}"
8+
return 0
9+
elif ! expr "$end_time" : '^[0-2][0-9]:[0-5][0-9]$' > /dev/null; then
10+
echo "$1"
11+
return 1
12+
else
13+
echo "$1"
14+
return 0
15+
fi
16+
}
17+
18+
if ! end_time=$(format_time "${end_time-$1}"); then
19+
echo "The given time '$end_time' is not valid. The expected format is 'hh:mm' or 'hh:mm:ss'."
20+
exit 1
21+
fi
22+
23+
echo \
24+
"{
25+
\"end_time\": \"$end_time\"
26+
}" \
27+
| load timer PUT @-
628

729
if filter .error > /dev/null; then
830
echo "Currently there is no running timer to stop."

0 commit comments

Comments
 (0)