Add reading docs

This commit is contained in:
Case Duckworth 2020-04-11 16:23:20 -05:00
parent 7c0e9ad05f
commit bb86f973a3
1 changed files with 34 additions and 2 deletions

View File

@ -5,6 +5,7 @@
: "${BREADNEWS:=/bread/news}"
: "${BREADDOCS:=/bread/docs}"
#shellcheck disable=1091
. /bread/site/lib.sh
usage()
@ -43,7 +44,8 @@ bread_news()
ENDOFHELP
exit
;;
n) num="$OPTARG" ;;
n) #shellcheck disable=2034
num="$OPTARG" ;;
s)
cmd="grep -R \"$OPTARG\" \"$BREADNEWS\" -l"
;;
@ -78,7 +80,37 @@ bread_news()
bread_docs()
{
true
while getopts hs:w opt; do
case "$opt" in
h)
cat <<-ENDOFHELP
ENDOFHELP
exit
;;
s)
grep -R "$OPTARG" "$BREADDOCS" -l|while read -r doc; do
echo " 🍞 🥖 🥐 "
printf '\033[34;1;4m%s\033[0m\n' "$(M title "$doc")"
printf '\033[34;1m%s\033[0m\n' "$(M date "$doc")"
C "$doc" | pandoc -t plain
done
echo " 🍞 🥖 🥐 "
return
;;
w)
;;
\?) return 2 ;;
*) return 2 ;;
esac
done
select doc in "$BREADDOCS"/*; do
echo " 🍞 🥖 🥐 "
printf '\033[34;1;4m%s\033[0m\n' "$(M title "$doc")"
printf '\033[34;1m%s\033[0m\n' "$(M date "$doc")"
C "$doc" | pandoc -t plain
done
echo " 🍞 🥖 🥐 "
}
main()