~tardypad/dotfiles

ref: HEAD dotfiles/utilities/report-tags -rwxr-xr-x 1.1 KiB
2a7e6d96Damien Tardy-Panis Add missing backup-dir in backup script for quickmarks 5 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# commands used:
# - column
# - git

init_variables() {
  COMMAND=${0##*/}

  TAGS='BUG'              # known bug that we live with
  TAGS="${TAGS}:IDEA"     # idea for improvement
  TAGS="${TAGS}:FIXME"    # should be refactored
  TAGS="${TAGS}:HACK"     # workaround around a bug or limitation
  TAGS="${TAGS}:OPTIMIZE" # should be optimized
  TAGS="${TAGS}:TODO"     # something else needs to be done
}

show_usage() {
  cat <<- EOF
	usage: ${COMMAND} [<options>]

	Report all code tags present in config files

	Options:
	  -h    show this message only
	EOF
}

parse_command_line() {
  while getopts h OPT; do
    case "${OPT}" in
      h) show_usage; exit 0 ;;
      ?) exit_error ;;
    esac
  done

  shift $(( OPTIND - 1 ))
}

# shellcheck disable=SC2120
exit_error() {
  [ -z "$1" ] || echo "${COMMAND}: $1"
  echo "Try '${COMMAND} -h' for more information."
  exit 1
} >&2

report_tags() {
  git grep -E "#($( echo "${TAGS}" | tr ':' '|' )):" . \
    | sed 's|\(.*\)/\([^:]*\):.*\(#[A-Z]*\): \(.*\)|\3@\1@\2@\4|' \
    | sort \
    | column -t -s@
}

init_variables
parse_command_line "$@"

report_tags