diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-03-11 18:33:02 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-03-11 18:33:02 +0100 |
commit | e6c1cacb60010ec75e02cf72acf34278417670fd (patch) | |
tree | 97e8f8042f4d8461e7cec9f403787bad20ffde9e /core/start |
initial commit (basic functionality)
Diffstat (limited to 'core/start')
-rwxr-xr-x | core/start | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/core/start b/core/start new file mode 100755 index 0000000..ae471ad --- /dev/null +++ b/core/start @@ -0,0 +1,39 @@ +#!/bin/sh +[ "$1" = "info" ] && echo "start or resume the timer" && exit 2 + +usage() { + cat << EOF +usage: + $subcmd [options] + +options: + -h, --help display this help text + -s, --skip skip to next lap, even if the timer is currently running + +EOF +} + +. "$core_path/lib" +. "$core_path/update" + +allow_skip=0 +while [ $# -gt 0 ] ; do + case "$1" in + -h|--help) usage && exit 0 ;; + -s|--skip) shift ; allow_skip=1 ;; + --) shift ; break ;; + *) err "unknown parameter: $1" ;; + esac +done + +if [ "$state" = 'running' ] ; then + [ $allow_skip -eq 0 ] && err "timer is already running, use -s to skip lap" + time="0.0" + lap=$(( $lap + 1 )) + . "$core_path/update" +fi + +time="$(echo "$now + $time" | bc)" +state='running' + +save_state |