forked from breadpunk/scripts
Add bread
This commit is contained in:
parent
2ae05a1413
commit
45e74e0c41
44
bread/bin/bread
Executable file
44
bread/bin/bread
Executable 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" "$@"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user