From 255e2c8fac40273a8cf001bf1f578a7f1bf18023 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Tue, 16 Aug 2022 18:49:03 -0300 Subject: bin/stopwatch: Add working version --- bin/stopwatch | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 bin/stopwatch diff --git a/bin/stopwatch b/bin/stopwatch new file mode 100755 index 0000000..3d5cd07 --- /dev/null +++ b/bin/stopwatch @@ -0,0 +1,65 @@ +#!/bin/sh +set -eu + + +usage() { + cat <<-'EOF' + Usage: + stopwatch + stopwatch -h + EOF +} + +help() { + cat <<-'EOF' + + Options: + -h, --help show this message + + + Run a TUI stopwatch. + + + Examples: + + Just run it: + + $ stopwatch + EOF +} + + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +while getopts 'h' flag; do + case "$flag" in + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + + +date "+%l:%M:%S%p: stopwatch started (^D to stop)" +time cat +date "+%l:%M:%S%p: stopwatch stopped" -- cgit v1.2.3