aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorziggys <ziggys@autistici.org>2018-08-04 18:27:29 -0400
committerziggys <ziggys@autistici.org>2018-08-04 18:27:29 -0400
commit11eedca916bfbaac1cfaa9e6fb70eedf41ee3820 (patch)
treeaaf132fbe88e1e0f0763cdda92ca05b3bab6aaa6
parent120cb08ffab0998d38a4255bc51936a67826bcd3 (diff)
downloadgsocial-cli-11eedca916bfbaac1cfaa9e6fb70eedf41ee3820.zip
gsocial-cli-11eedca916bfbaac1cfaa9e6fb70eedf41ee3820.tar
Add history to show command. Add show command to usage
-rwxr-xr-xgsocial-cli.sh48
1 files changed, 42 insertions, 6 deletions
diff --git a/gsocial-cli.sh b/gsocial-cli.sh
index e4ac11d..e3dc6e4 100755
--- a/gsocial-cli.sh
+++ b/gsocial-cli.sh
@@ -60,6 +60,20 @@ General Settings
To print actual settings run:
${SCRIPTNAME} show settings
+Show Command
+ ${SCRIPTNAME} show [options] <args>
+
+ Where options are:
+ settings <setting> i.e.: '${SCRIPTNAME} show settings d_account'
+ will show 'd_account' setting value in config
+ empty 'args' will result in full settings output
+ accounts <account> i.e.: '${SCRIPTNAME} show accounts myaccount'
+ will show profile info for 'myaccount'
+ empty 'args' will show all configured profiles info
+ history <account> i.e.: '${SCRIPTNAME} show history myaccount'
+ will show 'myaccount' history
+ empty 'args' will show history from all accounts
+
For more details about this script go to
Official Repository: https://git.p4g.club/git/gsocial-cli
Mirror Repository: https://gitgud.io/ziggys/gsocial-cli
@@ -535,6 +549,11 @@ DN="/dev/null"
XDGCONFIG="${XDG_HOME_CONFIG:=${HOME}/.config}"
CONFIGD="${XDGCONFIG}/${SCRIPTNAME}"
GSF="${CONFIGD}/${SCRIPTNAME}_config"
+CHECK_CURL="$(which curl)"
+test -z "${CHECK_CURL}" \
+ && printf "\\e%sfatal:\\[0m unsatisfied: \\e%scurl\\e[0m ...please install" \
+ "${diee_c}" "${warn_c}" \
+ && exit 0
test ! -d "${CONFIGD}" && mkdir -p "${CONFIGD}"
test ! -f "${GSF}" && create_gsf
test "$#" -lt 1 && usage "$@"
@@ -587,13 +606,30 @@ case "${SHOW}" in
printf "\\n"
fi
;;
-#TODO: isn't is obvious?
history | cache)
- echo "hist"
- ;;
-#TODO: again, obvious
- commands)
- echo "comm"
+ HISTORYT="$(mktemp -p "${TMPDIR}")"
+ if [ -z "${SHOWARGS}" ]; then
+ HISTORYF="$(find "${CONFIGD}" | grep "\.history$")"
+ for historyf in ${HISTORYF}; do
+ cat "${HISTORYF}" | sort -r | uniq >> "${HISTORYT}"
+ sed -i '/^ *$/ d' "${HISTORYT}"
+ awk 'BEGIN{FS=":;:"} \
+ {printf "\n" $1 " - " $6 "\n" $3 " - @" $2 "\n" $4 "\n"}' "${HISTORYT}" \
+ | more
+ done
+ else
+ HISTORYF="${CONFIGD}/${SHOWARGS}.history"
+ test ! -f "${HISTORYF}" \
+ && printf "\\e%sfatal:\\e[0m account has not history" \
+ "${diee_c}" \
+ && exit 0
+
+ cat "${HISTORYF}" | sort -r | uniq >> "${HISTORYT}"
+ sed -i '/^ *$/ d' "${HISTORYT}"
+ awk 'BEGIN{FS=":;:"} \
+ {printf "\n" $1 " - " $6 "\n" $3 " - @" $2 "\n" $4 "\n"}' "${HISTORYT}" \
+ | more
+ fi
;;
esac