kiss-help: Expand to displaying README files within repositories

This commit is contained in:
Dylan Araps 2021-08-27 07:21:42 +03:00
parent 6eb382f400
commit 993bea5ba0
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C

View File

@ -6,23 +6,35 @@ cd "$KISS_ROOT/usr/share/doc/kiss" 2>/dev/null || {
exit 1 exit 1
} }
! [ -f "${1:-.}/index.txt" ] || file=./${1:-.}/index.txt _q=$1
! [ -f "${1:-.}.txt" ] || file=./${1:-.}.txt
! [ -f "${1:-:}" ] || file=./${1:-.} ! [ -f "${_q:-.}/index.txt" ] || file=./${_q:-.}/index.txt
! [ -f "${_q:-.}.txt" ] || file=./${_q:-.}.txt
! [ -f "${_q:-:}" ] || file=./${_q:-.}
# Fallback to package READMEs.
# False positive, intended behavior.
# shellcheck disable=2046
[ "$file" ] || {
set -f
set +f -- $(kiss s "${_q##*/}")
file=${1:+"$1/README"}
}
# Fallback to search (allows 'kiss help firefox' to work). # Fallback to search (allows 'kiss help firefox' to work).
# False positive, intended behavior. # False positive, intended behavior.
# shellcheck disable=2046 # shellcheck disable=2046
[ "$file" ] || { [ "$file" ] || {
set -f set -f
set +f -- $(find . -name "${1##*/}.txt") set +f -- $(find . -name "${_q##*/}.txt")
file=$1 file=$1
} }
: "${file:=404.txt}" : "${file:=404.txt}"
cat <<EOF - "$file" | "${PAGER:-less}" cat <<EOF - "$file" | "${PAGER:-less}"
Reading $PWD/${file#./} Reading ${file#./}
________________________________________________________________________________ ________________________________________________________________________________
EOF EOF