@ -4,14 +4,6 @@
# Author E-Mail - terminalforlife@yahoo.com
# Author E-Mail - terminalforlife@yahoo.com
# Author GitHub - https://github.com/terminalforlife
# Author GitHub - https://github.com/terminalforlife
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Features:
#
#TODO: k
#
# Bugs:
#
# N/A
#------------------------------------------------------------------------------
Progrm=${0##*/}
Progrm=${0##*/}
@ -25,21 +17,23 @@ Usage(){
-D, --no-subdirs - Ignore the 'sheets/_*' subdirectories.
-D, --no-subdirs - Ignore the 'sheets/_*' subdirectories.
-N, --no-preview - Omit the preview of each triggered line.
-N, --no-preview - Omit the preview of each triggered line.
-S, --no-summary - Omit the summary before $Progrm exits.
-S, --no-summary - Omit the summary before $Progrm exits.
-W, --no-whilelist - Do not use the whitelist file.
-c, --colorize - Provide color via esscape sequences.
-c, --colorize - Provide color via esscape sequences.
-l, --limit [INT] - Override the limit of 80 columns.
-l, --limit [INT] - Override the limit of 80 columns.
-p, --pager - Use less(1) to page the output.
-p, --pager - Use less(1) to page the output.
-w, --whitelist [FILE] - Whitelist files stored within .
-w, --wl-file [FILE] - Use an alternative whitelist file .
Whitelisting uses the following format, by way of example:
Files to whitelist must be placed line-by-line; one path per line.
file ' cheat.sheets/sheets/_perl/1line'
cheat.sheets/sheets/_perl/1line
file ' cheat.sheets/sheets/find'
cheat.sheets/sheets/find
The file paths to provide must begin with 'cheat.sheets/' to indicate
The file paths to provide must begin with 'cheat.sheets/' to indicate
the root of the repository, otherwise this feature will fail.
the root of the repository, otherwise this feature will fail.
The location of the whitelisting file ('$Progrm-exclude') must remain
The location of the whitelisting file ('$Progrm-excludes') must
in the same directory in which $Progrm is stored.
remain in the same directory in which $Progrm is stored, unless
otherwise specified.
EOF
EOF
}
}
@ -48,6 +42,7 @@ Err(){
[ $1 -gt 0 ] && exit $1
[ $1 -gt 0 ] && exit $1
}
}
WLFile='lenchk-excludes'
MaxCols=80
MaxCols=80
while [ "$1" ]; do
while [ "$1" ]; do
@ -70,6 +65,16 @@ while [ "$1" ]; do
NoSummary='True' ;;
NoSummary='True' ;;
--no-subdirs|-D)
--no-subdirs|-D)
NoSubDirs='True' ;;
NoSubDirs='True' ;;
--no-whitelist|-W)
NoWhiteList='True' ;;
--wl-file|-w)
shift
if [ -z "$1" ]; then
Err 1 'No alternative whitelist file provided.'
else
WLFile=$1
fi ;;
*)
*)
Err 1 'Incorrect option(s) specified.' ;;
Err 1 'Incorrect option(s) specified.' ;;
esac
esac
@ -93,9 +98,24 @@ Main(){
Dirs=(../sheets/*)
Dirs=(../sheets/*)
[ "$NoSubDirs" == 'True' ] || Dirs+=(../sheets/*/*)
[ "$NoSubDirs" == 'True' ] || Dirs+=(../sheets/*/*)
# If the whitelist file exists, use it, unless whitelisting is disabled.
# Keeping this test outside of the loop to avoid unnecessary processing.
if [ "$NoWhiteList" != 'True' ] && [ -f "$WLFile" ]; then
# Read the whitelist file, line-by-line, generating an array thereof.
Whitelisted=()
while read; do
Whitelisted+=("../${REPLY#cheat.sheets/}")
done < "$WLFile"
fi
for File in "${Dirs[@]}"; {
for File in "${Dirs[@]}"; {
[ -f "$File" ] || continue
[ -f "$File" ] || continue
# If the current file matches one which is whitelisted, skip it.
for CurWL in "${Whitelisted[@]}"; {
[ "$File" == "$CurWL" ] && continue 2
}
HaveBeenHit='False'
HaveBeenHit='False'
LineNum=0
LineNum=0