TheRepoClub-DotFiles/localbin/.local/bin/kiss/kiss-help
The-Repo-Club 127f414edb
Added Kiss package manager
Signed-off-by: The-Repo-Club <wayne6324@gmail.com>
2022-10-02 12:59:09 +01:00

41 lines
906 B
Bash
Executable File

#!/bin/sh -e
# Read KISS documentation
cd "$KISS_ROOT/usr/share/doc/kiss" 2>/dev/null || {
printf 'Documentation is missing from /usr/share/doc/kiss\n'
exit 1
}
_q=$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).
# False positive, intended behavior.
# shellcheck disable=2046
[ "$file" ] || {
set -f
set +f -- $(find . -name "${_q##*/}.txt")
file=$1
}
: "${file:=404.txt}"
cat <<EOF - "$file" | "${PAGER:-less}"
Reading ${file#./}
________________________________________________________________________________
EOF