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
This commit is contained in:
Dylan Lom 2021-05-16 19:13:00 +10:00
parent 93d7497e7d
commit 569ee93828
2 changed files with 23 additions and 0 deletions

View File

@ -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";

View File

@ -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))"
}