Plan 9 from Bell Labs’s /usr/web/sources/contrib/josh/rc/mb/read

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

# Awk | sed pipeline from http://plan9.stanleylieber.com/rc/tw

rfork en

flagfmt='p,r,h url'
args='[user]'
if(! ifs=() eval `{aux/getflags $*} || ! ~ $#* 0 1){
	aux/usage
	exit usage
}

conflicting=($flagp $flagr)
if(~ $#conflicting 2){
	echo 'use only one of -p or -r' >[1=2]
	exit usage
}

if(~ $#mbapiurl 1)
	url=$mbapiurl
if(~ $#flagh 1)
	url=$flagh
if(! ~ $#url 1){
	echo 'set $mbapiurl or give -h url' >[1=2]
	exit usage
}

if(~ $#mbuser 1)
	user=$mbuser
if(~ $#1 1)
	user=$1

q=/statuses/home_timeline/$user.xml
if(~ $#flagp 1)
	q=/statuses/public_timeline.xml
if(~ $#flagr 1)
	q=/statuses/mentions/$user.xml
hget $url^$q |
awk '/<text>|<screen_name>/ {a[i++]=$0;} END {for (j=i-1; j>=0;) print a[j--] "<p>";}' |
sed 's/<\/screen_name><p>/<\/screen_name>:/g' |
htmlfmt

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].