aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorziggys <ziggys@autistici.org>2018-08-01 20:36:34 -0400
committerziggys <ziggys@autistici.org>2018-08-01 20:36:34 -0400
commit7aa46857cf3f50328da680c7a4b607f64e4f5201 (patch)
tree18b6326a6eb807a303ed76e5e6beebeb7a995d90
parent6f66aaf901f2f0eabc58fec6e4a0b550bd8bdfa1 (diff)
downloadgsocial-cli-7aa46857cf3f50328da680c7a4b607f64e4f5201.zip
gsocial-cli-7aa46857cf3f50328da680c7a4b607f64e4f5201.tar
Add informative headers and user info
-rwxr-xr-xgsocial-cli.sh68
1 files changed, 28 insertions, 40 deletions
diff --git a/gsocial-cli.sh b/gsocial-cli.sh
index 7f91747..e8d2d4e 100755
--- a/gsocial-cli.sh
+++ b/gsocial-cli.sh
@@ -188,34 +188,18 @@ acc_conf () {
# obtain user info
user_info () {
UINFOF="$(mktemp -p "${TMPDIR}")"
- INODE="${NODE}"
- IUSER="${USER}"
- test ! -z "${RNODE}" && INODE="${RNODE}" && IUSER="${GETUSER}"
iget_api="${INODE}/api/users/show.xml?screen_name=${IUSER}"
curl -s "${iget_api}" > "${UINFOF}"
- USERID="$(sed '/^ <id>/ !d' "${UINFOF}")"
- USERID="${USERID## <id>}"
- USERID="${USERID%%<*}"
- DESCRIPTION="$(sed '/^ <description>/ !d' "${UINFOF}")"
- DESCRIPTION="${DESCRIPTION## <description>}"
- DESCRIPTION="${DESCRIPTION%%<*}"
- DESCRIPTION="${DESCRIPTION%%&*}"
- STATUSESQ="$(sed '/^ <statuses_count>/ !d' "${UINFOF}")"
- STATUSESQ="${STATUSESQ## <statuses_count>}"
- STATUSESQ="${STATUSESQ%%<*}"
- FOLLOWSQ="$(sed '/^ <friends_count>/ !d' "${UINFOF}")"
- FOLLOWSQ="${FOLLOWSQ## <friends_count>}"
- FOLLOWSQ="${FOLLOWSQ%%<*}"
- FOLLOWERSQ="$(sed '/^ <followers_count>/ !d' "${UINFOF}")"
- FOLLOWERSQ="${FOLLOWERSQ## <followers_count>}"
- FOLLOWERSQ="${FOLLOWERSQ%%<*}"
- GROUPSQ="$(sed '/^ <groups_count>/ !d' "${UINFOF}")"
- GROUPSQ="${GROUPSQ## <groups_count>}"
- GROUPSQ="${GROUPSQ%%<*}"
-
- printf "\\e%s%s@%s\\n" "${warn_c}" "${USER}" "${NONODE}"
+ USERID="$(sed '/^ <id>/ !d; s/ *<[^>]*> *//g' "${UINFOF}")"
+ DESCRIPTION="$(sed '/^ <description>/ !d; s/ *<[^>]*> *//g' "${UINFOF}")"
+ STATUSESQ="$(sed '/^ <statuses_count>/ !d; s/ *<[^>]*> *//g' "${UINFOF}")"
+ FOLLOWSQ="$(sed '/^ <friends_count>/ !d; s/ *<[^>]*> *//g' "${UINFOF}")"
+ FOLLOWERSQ="$(sed '/^ <followers_count>/ !d; s/ *<[^>]*> *//g' "${UINFOF}")"
+ GROUPSQ="$(sed '/^ <groups_count>/ !d; s/ *<[^>]*> *//g' "${UINFOF}")"
+
+ printf "\\e%s%s@%s [%s]\\n" "${warn_c}" "${IUSER}" "${NONODE}" "${USERID}"
printf "\\e%s%s\\e[0m\\n" "${info_c}" "${DESCRIPTION}"
printf "Statuses: \\e%s%s\\e[0m\\t" "${warn_c}" "${STATUSESQ}"
printf "Followers: \\e%s%s\\e[0m\\t" "${warn_c}" "${STATUSESQ}"
@@ -236,11 +220,13 @@ verify_credentials () {
# get timeline, public, mentions
tget () {
-
test "${ACCNAME}" = "notprovided" \
&& printf "\\e%sfatal:\\e%s account name not provided\\n\\e[0m" \
"${diee_c}" "${info_c}"
+ printf "...retrieving last \\e%s%s\\e[0m statuses from \\e%s%s\\e[0m\\n\\n" \
+ "${good_c}" "${RETR}" "${good_c}" "${TGET}"
+
TIMELINEF="$(mktemp -p "${TMPDIR}")"
OUTPUT0="$(mktemp -p "${TMPDIR}")"
OUTPUT1="$(mktemp -p "${TMPDIR}")"
@@ -276,6 +262,8 @@ tget () {
get_uri="${GETATAG}.xml&count=${RETR:=20}"
get_api="${NODE}/api/statusnet/tags/timeline/${get_uri}"
TGET="${TGET} #${GETATAG}"
+ warn_c="[0;36m"
+ printf "\\e%sTag: \\e%s%s\\e[0m\\n" "${info_c}" "${warn_c}" "${GETATAG}"
;;
"user")
RNODE="https://${RUSER##*@}"
@@ -283,13 +271,15 @@ tget () {
get_uri="include_rst=true&screen_name=${GETUSER}&count=${RETR:=20}"
get_api="${RNODE}/api/statuses/user_timeline.xml?${get_uri}"
TGET="${TGET} ${RUSER}"
+ IUSER="${GETUSER}"
+ INODE="${RNODE}"
+ warn_c="[0;36m"
+ printf "\\e%sUser Info:\\e[0m\\n" "${info_c}"
+ user_info
+ printf "\\n"
;;
esac
- user_info
- printf "...retrieving last \\e%s%s\\e[0m statuses from \\e%s%s\\e[0m\\n\\n" \
- "${good_c}" "${RETR}" "${good_c}" "${TGET}"
-
verify_credentials
curl -s -u "$USER:$PASSWORD" "${data_api}" "${get_api}" \
> "${TIMELINEF}"
@@ -389,9 +379,6 @@ tget () {
rfd () {
ACTION="$(echo "${action_api}" | awk 'BEGIN{FS="/"}{printf $2}')"
- # print some header
- printf "\\e%s%s\\e[0m v%s\\n" "${good_c}" "${SCRIPTNAME}" "${VERSION}"
-
if [ ! -f "${HISTORY}" ]; then
printf "\\e%swarning: no history file was found.\\n" "${warn_c}"
printf "\\e%s%s is still available, but expect missbehavior.\\e[0m\\n" \
@@ -415,19 +402,19 @@ rfd () {
case "${ACTION}" in
"create")
- printf "Favoriting a status by \\e%s%s\\e[0m in \\e%s%s:\\e[0m\\n\\n" \
+ printf "...favoriting status by \\e%s%s\\e[0m in \\e%s%s:\\e[0m\\n\\n" \
"${good_c}" "${TUSER}" "${good_c}" "${NONODE}"
printf "Status details:\\n"
printf "\\e%s[%s] %s\\n\\n" "${info_c}" "${TID}" "${TSTS}"
;;
"retweet")
- printf "Repating a status by \\e%s%s\\e[0m in \\e%s%s:\\e[0m\\n\\n" \
+ printf "...repeating a status by \\e%s%s\\e[0m in \\e%s%s:\\e[0m\\n\\n" \
"${good_c}" "${TUSER}" "${good_c}" "${NONODE}"
printf "Status details:\\n"
printf "\\e%s[%s] %s\\n\\n" "${info_c}" "${TID}" "${TSTS}"
;;
"destroy")
- printf "Deleting a status by \\e%syou\\e[0m in \\e%s%s:\\e[0m\\n\\n" \
+ printf "...deleting a status by \\e%syou\\e[0m in \\e%s%s:\\e[0m\\n\\n" \
"${good_c}" "${good_c}" "${NONODE}"
printf "Status details:\\n"
printf "\\e%s[%s] %s\\n\\n" "${info_c}" "${TID}" "${TSTS}"
@@ -448,9 +435,7 @@ rfd () {
# post
post () {
POSTF="$(mktemp -p "${TMPDIR}")"
- # print some header
- printf "\\e%s%s\\e[0m v%s\\n" "${good_c}" "${SCRIPTNAME}" "${VERSION}"
-
+
if [ ! -f "${HISTORY}" ]; then
printf "\\e%swarning: no history file was found.\\n" "${warn_c}"
printf "\\e%s%s is still available, but expect missbehavior.\\e[0m\\n" \
@@ -523,7 +508,7 @@ post () {
"${info_c}" "${warn_c}" "${METHOD}" \
&& exit 0
- printf "Sending a \\e%s%s\\e[0m status to \\e%s%s:\\e[0m\\n\\n" \
+ printf "...sending a \\e%s%s\\e[0m status to \\e%s%s:\\e[0m\\n\\n" \
"${good_c}" "${METHOD}" "${good_c}" "${NONODE}"
printf "Message content:\\n"
printf "\\e%s%s\\n\\n\\e[0m" "${info_c}" "${STATUS}"
@@ -606,7 +591,10 @@ PASSWORD="$(echo "${PASSWORD}" | base64 -d -)"
NODE="$(echo "${NODE}" | base64 -d -)"
NONODE="${NODE##*//}"
HISTORY="${CONFIGD}/${ACCNAME}.history" ;
-
+IUSER="${USER}"
+INODE="${NODE}"
+user_info
+
# read options from commandline
test "$#" -lt 1 && usage "$@"
while getopts ":c:t:T:m:e:U:r:f:d:R:q:psh" opt; do