File:  [Coherent Logic Development] / freem / scripts / fmd-todo
Revision 1.1: download - view: text, annotated - select for diffs
Thu Apr 10 02:17:49 2025 UTC (8 weeks, 2 days ago) by snw
Branches: MAIN
CVS tags: HEAD
Add fmd-todo

#!/usr/bin/env bash

#
#   $Id: fmd-todo,v 1.1 2025/04/10 02:17:49 snw Exp $
#    Find files that need work
#
#  
#   Author: Serena Willis <snw@coherent-logic.com>
#    Copyright (C) 2025 Coherent Logic Development LLC
#
#
#   This file is part of FreeM.
#
#   FreeM is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   FreeM is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Affero Public License for more details.
#
#   You should have received a copy of the GNU Affero Public License
#   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
#
#   $Log: fmd-todo,v $
#   Revision 1.1  2025/04/10 02:17:49  snw
#   Add fmd-todo
#
#
# SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
# SPDX-License-Identifier: AGPL-3.0-or-later
#

PGM=$(basename $0)
SCRIPT_DIR=$(dirname "$0")

source "${SCRIPT_DIR}/_fmd_common.bash"

function usage() {
    echo
    echo "Finds FreeM source files with TODO comments"
    echo    
    echo "usage:  "
    echo
    echo "  fmd todo"
    echo
    exit 0
}

if [[ $1 == "help" ]]
then
    usage
fi

if [[ $# == 0 ]]
then
    echo "lint:  must be run from 'fmd lint'"
    exit 1
fi

FMD=$1

for FILE in src/*.[ch]
do
    grep "TODO:" "${FILE}" &> /dev/null
    if [[ $? == 0 ]]
    then
        TMPF=$(mktemp)
        cat "${FILE}" | nl -ba > ${TMPF}
        echo "${FILE}:"
        while read LINE
        do
            LNO=$(echo "${LINE}" | awk '{ print $1 }')
            echo "${LINE}" | grep "TODO:" &> /dev/null
            if [[ $? == 0 ]]
            then
                RPART=$(echo "${LINE}" | cut -d: -f2 | sed 's/\*\///g')
                printf "\t- %s:  %s\n" "${LNO}" "${RPART}"
            fi
        done < "${TMPF}"
        rm -f "${TMPF}"
    fi
done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>