Change time signature

This commit is contained in:
Case Duckworth 2020-04-11 20:21:05 +00:00
parent ae941d3477
commit 0f3e148fd3
1 changed files with 44 additions and 3 deletions

View File

@ -17,14 +17,55 @@ usage()
🍞 🥖 🥐
commands:
- news: read the news
for detailed usage of each command,
run bread COMMAND -h
🍞 🥖 🥐
ENDOFUSAGE
exit 1
}
bread_news()
{
n="${1:-4}"
for art in $(find "$BREADNEWS" -type f | sort -nr | head -n"$n"); do
num=4
while getopts hn:s:w opt; do
case "$opt" in
h)
cat <<-ENDOFHELP
bread news : read the news
usage: bread news [-n NUM] [-s QUERY] [-w]
-n NUM read NUM newest articles. default: 4
-s QUERY search for QUERY in news database
-w write a new article (admin only)
ENDOFHELP
exit
;;
n) num="$OPTARG" ;;
s)
query="$OPTARG"
;;
w)
groups "$USER" | grep -q admin || {
echo "You're not an admin!"
exit 3
}
article="$BREADNEWS/$(date +%F)@$(date +%H:%M).md"
cat <<-ENDOFARTICLE >"$article"
title
author $USER
date $(date +%F)
ENDOFARTICLE
$EDITOR "$article"
exit
;;
\?) return 2 ;;
*) return 2 ;;
esac
done
for art in $(find "$BREADNEWS" -type f | sort -nr | head -n "$num"); do
echo " 🍞 🥖 🥐 "
printf '\033[34;1;4m%s\033[0m\n' "$(M title "$art")"
printf '\033[34;1m%s\033[0m\n' "$(M date "$art")"
@ -45,7 +86,7 @@ main()
shift "$((OPTIND - 1))"
cmd="$1"; shift
bread_"$cmd" "$@"
bread_"$cmd" "$@" || exit $?
}
main "$@"