Add bread

This commit is contained in:
Case Duckworth 2020-04-11 14:56:00 -05:00
parent 2ae05a1413
commit 45e74e0c41
1 changed files with 44 additions and 0 deletions

44
bread/bin/bread Executable file
View File

@ -0,0 +1,44 @@
#!/bin/bash
# bread: do stuff on breadpunk
# by breadw
: "${BREADNEWS:=/bread/news}"
: "${BREADDOCS:=/bread/docs}"
usage()
{
cat <<-ENDOFUSAGE
🍞 let's get this 🥖 B R E A D 🥐
a tool for breadpunk.club
🍞 🥖 🥐
usage: bread [-h] COMMAND [OPTIONS]
🍞 🥖 🥐
commands:
- news: read the news
ENDOFUSAGE
exit 1
}
bread_news()
{
n="${1:-4}"
for art in $(find "$BREADNEWS" -type f | sort -nr | head -n"$n"); do
echo " 🍞 🥖 🥐 "
cat "$art"
done
}
main()
{ # entry point
while getopts h opt; do
case "$opt" in
h) usage ;;
\?) exit 2 ;;
*) exit 2 ;;
esac
done
shift "$((OPTIND - 1))"
cmd="$1"; shift
bread_"$cmd" "$@"
}