From d6f05e96cb5b139b1ea0ad7a166205d9e31c2440 Mon Sep 17 00:00:00 2001
From: Colin Okay <colin@cicadas.surf>
Date: Mon, 15 Aug 2022 07:13:37 -0500
Subject: [refactor] scripts to use env var for users

---
 threadcat-list.sh  |  8 +-------
 threadcat-read.sh  | 17 ++++++-----------
 threadcat-write.sh | 20 +++++++-------------
 3 files changed, 14 insertions(+), 31 deletions(-)

diff --git a/threadcat-list.sh b/threadcat-list.sh
index e3ccd67..420a9ff 100755
--- a/threadcat-list.sh
+++ b/threadcat-list.sh
@@ -1,10 +1,4 @@
 #!/bin/bash
 
-CICADAS_USER=$1
+ssh $CICADAS_USER@cicadas.surf "ls -lt /opt/threadcat/" | awk '{ s = ""; for (i = 6; i <= 9; i++) s = s $i " "; print s }'
 
-if [ ! -z "${CICADAS_USER}" ]; then
-    ssh $CICADAS_USER@cicadas.surf "ls -lt /opt/threadcat/" | awk '{ s = ""; for (i = 6; i <= 9; i++) s = s $i " "; print s }'
-else
-    echo You did not provide a user name
-    echo USAGE: threacat-list USER
-fi
diff --git a/threadcat-read.sh b/threadcat-read.sh
index 291cf9e..031ccbe 100755
--- a/threadcat-read.sh
+++ b/threadcat-read.sh
@@ -1,16 +1,11 @@
 #!/bin/bash
 
-CICADAS_USER=$1
-THREAD_NAME=$2
+THREAD_NAME=$1
 
-if [ ! -z "${CICADAS_USER}" ]; then
-    if [ ! -z "${THREAD_NAME}" ]; then
-        ssh $CICADAS_USER@cicadas.surf "cat /opt/threadcat/$THREAD_NAME"
-    else
-        echo You did not provide a thread name.
-        echo USAGE: "cat <YOURMESSAGE> | threadcat-write USER THREAD_NAME"
-    fi
+if [ ! -z "${THREAD_NAME}" ]; then
+    ssh $CICADAS_USER@cicadas.surf "cat /opt/threadcat/$THREAD_NAME"
 else
-    echo You did not provide a user name.
-    echo USAGE: cat "<YOURMESSAGE> | threadcat-write USER THREAD_NAME"
+    echo You did not provide a thread name.
+    echo USAGE: "threadcat read THREAD_NAME"
 fi
+
diff --git a/threadcat-write.sh b/threadcat-write.sh
index e328fc2..78b436f 100755
--- a/threadcat-write.sh
+++ b/threadcat-write.sh
@@ -1,20 +1,14 @@
 #!/bin/bash
 
-CICADAS_USER=$1
-THREAD_NAME=$2
+THREAD_NAME=$1
 
-
-if [ ! -z "${CICADAS_USER}" ]; then
-    if [ ! -z "${THREAD_NAME}" ]; then
-        cat - | ssh $CICADAS_USER@cicadas.surf "umask 002 && echo `whoami` -- `date` >> /opt/threadcat/$THREAD_NAME && cat - >> /opt/threadcat/$THREAD_NAME"
-        echo Posted to $THREAD_NAME
-    else
-        echo You did not provide a thread name.
-        echo USAGE: "cat <YOURMESSAGE> | threadcat-write USER THREAD_NAME"
-    fi
+if [ ! -z "${THREAD_NAME}" ]; then
+    cat - | ssh $CICADAS_USER@cicadas.surf "umask 002 && echo `whoami` -- `date` >> /opt/threadcat/$THREAD_NAME && cat - >> /opt/threadcat/$THREAD_NAME"
+    echo Posted to $THREAD_NAME
 else
-    echo You did not provide a user name.
-    echo USAGE: cat "<YOURMESSAGE> | threadcat-write USER THREAD_NAME"
+    echo You did not provide a thread name.
+    echo USAGE: "cat <YOURMESSAGE> | threadcat write THREAD_NAME"
 fi
 
 
+
-- 
cgit v1.2.3