add -s option to news

This commit is contained in:
Case Duckworth 2020-04-11 20:53:03 +00:00
parent 0f3e148fd3
commit 7c0e9ad05f
1 changed files with 9 additions and 2 deletions

View File

@ -17,6 +17,7 @@ usage()
🍞 🥖 🥐
commands:
- news: read the news
- docs: read documents
for detailed usage of each command,
run bread COMMAND -h
@ -28,6 +29,7 @@ usage()
bread_news()
{
num=4
artcmd="find \"$BREADNEWS\" -type f | sort -nr | head -n \"\$num\""
while getopts hn:s:w opt; do
case "$opt" in
h)
@ -43,7 +45,7 @@ bread_news()
;;
n) num="$OPTARG" ;;
s)
query="$OPTARG"
cmd="grep -R \"$OPTARG\" \"$BREADNEWS\" -l"
;;
w)
groups "$USER" | grep -q admin || {
@ -65,7 +67,7 @@ bread_news()
esac
done
for art in $(find "$BREADNEWS" -type f | sort -nr | head -n "$num"); do
for art in $(eval "$artcmd"); 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")"
@ -74,6 +76,11 @@ bread_news()
echo " 🍞 🥖 🥐 "
}
bread_docs()
{
true
}
main()
{ # entry point
while getopts h opt; do