<commit_before>#/bin/bash

# TODO: better display
# TODO: ignore some files / directories
# TODO: differ fixme & todo

# $1 <- error msg
# $2 <- code return
function _error() {
  echo $1 >&2
  exit $2
}



GREP=$(which grep)

if [[ -z $GREP ]]; then
  _error "grep is not installed." 1
fi

function _tdfx() {
  $GREP -Ern "FIXME|TODO" $*
}

_tdfx $*<commit_msg>tdfx.bash: change grep used to cat/sed to display multiline comments<commit_after>#/bin/bash

# TODO: iterating over files instead of cat them all in the same tme.
# TODO: add CLI parser (ignore, fixme, todo, ...)
# TODO: better display

# $1 <- error msg
# $2 <- code return
function _error() {
  echo $1 >&2
  exit $2
}

CAT=$(which cat)
SED=$(which sed)
if [[ -z $CAT ]]; then
  _error "cat is not installed." 1
fi
if [[ -z $SED ]]; then
  _error "sed is not installed." 1
fi

USAGE=<<-EOF
  TDFX helper.
  WIP
EOF

function _tdfx() {
  # FIXME: iterate here.
  $CAT -n $* | $SED '/\/\\*/,/\\*\//{H;d;};x;/TODO/!d'
}

_tdfx $*
{'fraction_non_alphanumeric': 0.17272727272727273, 'fraction_numerical': 0.013131313131313131, 'mean_word_length': 3.0284552845528454, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6733145', 'n_tokens_mistral': 414, 'n_tokens_neox': 392, 'n_words': 132}