#!/bin/rc
# Based on 'tweet' by anothy.
rfork en
flagfmt='d,h url'
args='[text]'
if(! ifs=() eval `{aux/getflags $*}){
aux/usage
exit usage
}
#url=https://identi.ca/api
if(~ $#µblog 1)
url=$µblog
if(~ $#flagh 1)
url=$flagh
if(! ~ $#url 1){
echo 'set $µblog or give -h url' >[1=2]
exit usage
}
if(~ $#* 0)
msg=`{read}
if not
msg=$"*
MAXC=140
msgc=`{echo -n $msg |wc -r}
if(! ~ $msgc `{seq $MAXC}) {
echo Not posted. Wanted ≤ $MAXC characters, got $msgc. >[1=2]
exit length
}
q=statuses/update.json
ofile=/dev/null
if(~ $#flagd 1)
ofile=/fd/2
hget -p 'source=µb/write&status='^$"msg $url/$q > $ofile
|