diff options
| author | EuAndreh <eu@euandre.org> | 2022-01-04 15:42:05 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2022-01-04 15:42:05 -0300 |
| commit | 4b54ceae03549d234ab8f996607b391096ca69d4 (patch) | |
| tree | 5d5f891dc4a01ddd9768b60e384b575249278cae | |
| parent | scripts/: Move executables to src/bin/, and add a proper CLI interface to them (diff) | |
| download | dotfiles-4b54ceae03549d234ab8f996607b391096ca69d4.tar.gz dotfiles-4b54ceae03549d234ab8f996607b391096ca69d4.tar.xz | |
scripts/todo: Remove script, which became the "td" project
| -rwxr-xr-x | scripts/todo | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/scripts/todo b/scripts/todo deleted file mode 100755 index 69057843..00000000 --- a/scripts/todo +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<EOF -Usage: - $0 [OPTIONS] [TITLE] - -Options: - -h Show this help message - -c Commit directly only with the title, without adding a description - -t TYPE Pick the type of todo to be added (default: task) - -m MESSAGE_TITLE The message (default: FIXME) -EOF -} - -uuid() { - # Taken from: - # https://serverfault.com/a/799198 - od -xN20 /dev/urandom | \ - head -1 | \ - awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}' -} - -insert_at_line() { - N="$1" - F="$2" - TMP="$(mktemp)" - printf '%s\n\n%s\n\n%s\n' \ - "$(head "-n$N" "$F")" \ - "$(cat -)" \ - "$(tail "-n+$((N+1))" "$F")" \ - > "$TMP" - mv "$TMP" "$F" -} - -SHORT=false -TYPE=task -MESSAGE=FIXME -while getopts 'hct:m:' flag; do - case "$flag" in - h) - usage - exit - ;; - c) - SHORT=true - ;; - t) - TYPE="$OPTARG" - ;; - m) - MESSAGE="$OPTARG" - ;; - *) - ;; - esac -done - -case "$TYPE" in - task|bug|improvement|question) - ;; - *) - echo "Unsupported type: $TYPE" - exit 2 - ;; -esac - -ID="#$TYPE-$(uuid)" -TITLE_LINE="$(printf '## TODO %s {%s}\n- TODO in %s\n' "$MESSAGE" "$ID" "$(date -I)")" -TYPE_LINE="$(grep -in "^# ${TYPE}s$" TODOs.md | cut -d: -f1)" -INSERT_LINE=$((TYPE_LINE + 1)) - -if [ "$SHORT" = 'true' ] && [ "$MESSAGE" != 'FIXME' ]; then - echo "$TITLE_LINE" | insert_at_line "$INSERT_LINE" TODOs.md -else - printf '%s\n\n---\n\nFIXME\n' "$TITLE_LINE" | vipe | insert_at_line "$INSERT_LINE" TODOs.md -fi - -git reset . -git add TODOs.md -git commit -m "TODOs.md: Add $ID" |
