From 569ee93828fa796f22e69bb0acfc2f2b6ad58199 Mon Sep 17 00:00:00 2001 From: Dylan Lom Date: Sun, 16 May 2021 19:13:00 +1000 Subject: [PATCH] Add todo command to gut gut todo `git grep`'s for todo's and fixme's based on flags. By default it outputs a summary (-c). Add very important comment to confirm --- src/confirm.c | 1 + src/gut.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/confirm.c b/src/confirm.c index 2bfe73d..c2f7a6e 100644 --- a/src/confirm.c +++ b/src/confirm.c @@ -71,6 +71,7 @@ main(int argc, const char *argv[]) // Options provided as args if (argc > 1) return confirm(argv[0], argv+1, argc-1); + // Options not provided -- use defaults const char **opts = STR_EALLOC(2); opts[0] = "y"; opts[1] = "n"; diff --git a/src/gut.sh b/src/gut.sh index 40efb80..72eaab5 100755 --- a/src/gut.sh +++ b/src/gut.sh @@ -64,6 +64,28 @@ status() { git status --short } +todo() { + while [ "$#" -gt 0 ]; do + case "$1" in + "-d") detail=true ;; + "-c") colorize=true ;; + "-f") fixme=true ;; + *) break ;; + esac + shift + done + + re="(TODO$(truthy $fixme && echo '|FIXME')):" + color="--color=$(truthy $colorize && echo 'always' || echo 'never')" + if truthy $detail; then + # TODO: Setting color=always breaks alignment for some reason + git grep -nE "$color" $@ "$re" | \ + sed 's/\([^:]*:[^:]*\):[ \t]*\(.*\)/\1\t\2/' + else + git grep -ncE $@ '(TODO|FIXME):' + fi +} + whoami() { echo "$(git config user.name) ($(git config user.email))" }