diff options
author | Colin Okay <colin@cicadas.surf> | 2022-08-15 11:40:24 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-08-15 11:40:24 -0500 |
commit | 331eef1cdcc2fb183ca6ac3945b332dfd8581bff (patch) | |
tree | 6d4db3e6e6a464298c71d0831039ecd7fccdf974 | |
parent | 921ff76178a468552189137076193ed70dd7ffbe (diff) |
[add] [feature] sub-boards
-rwxr-xr-x | threadcat | 18 | ||||
-rwxr-xr-x | threadcat-del.sh | 11 | ||||
-rwxr-xr-x | threadcat-list.sh | 18 | ||||
-rwxr-xr-x | threadcat-read.sh | 11 | ||||
-rwxr-xr-x | threadcat-write.sh | 20 |
5 files changed, 59 insertions, 19 deletions
@@ -9,20 +9,20 @@ if [ -z "${THREADCAT_USER}" ]; then fi if [ -z "${THREADCAT_SUBCOMMAND}" ]; then - echo "USAGE: threadcat <COMMAND> [THREAD]" + echo "USAGE: threadcat <COMMAND> [BOARD] [THREAD]" echo commands are: - echo " list lists threads, most recent first" - echo " read [THREAD] reads a thread, printing to stdout" - echo " write [THREAD] posts to THREAD from stdin" - echo " del [THREAD] delete a thread" + echo " list [BOARD] lists threads, most recent first" + echo " read [BOARD] THREAD reads a thread, printing to stdout" + echo " write [BOARD] THREAD posts to THREAD from stdin" + echo " del [BOARD] THREAD delete a thread" exit 0 fi case "$THREADCAT_SUBCOMMAND" in - "list" ) threadcat-list.sh ;; - "read" ) threadcat-read.sh $2 ;; - "write" ) threadcat-write.sh $2 ;; - "del" ) threadcat-delete.sh $2 ;; + "list" ) threadcat-list.sh $2 ;; + "read" ) threadcat-read.sh $2 $3 ;; + "write" ) threadcat-write.sh $2 $3 ;; + "del" ) threadcat-del.sh $2 $3 ;; * ) echo Unknown subcommand $THREADCAT_SUBCOMMAND echo commands are list, read, write, del;; esac diff --git a/threadcat-del.sh b/threadcat-del.sh index cd71da6..c1087ba 100755 --- a/threadcat-del.sh +++ b/threadcat-del.sh @@ -1,11 +1,18 @@ #!/bin/bash -THREAD_NAME=$1 +BOARD_NAME=$1 +THREAD_NAME=$2 + +if [ -z "${THREAD_NAME}" ]; then + THREAD_NAME=$BOARD_NAME +else + THREAD_NAME=$BOARD_NAME/$THREAD_NAME +fi if [ ! -z "${THREAD_NAME}" ]; then ssh $THREADCAT_USER "rm /opt/threadcat/$THREAD_NAME" else echo You did not provide a thread name. - echo USAGE: "threadcat del THREAD_NAME" + echo USAGE: "threadcat del [BOARD] THREAD" fi diff --git a/threadcat-list.sh b/threadcat-list.sh index 89f490e..3f19691 100755 --- a/threadcat-list.sh +++ b/threadcat-list.sh @@ -1,4 +1,20 @@ #!/bin/bash -ssh $THREADCAT_USER "ls -lt /opt/threadcat/" | awk '{ s = ""; for (i = 6; i <= 9; i++) s = s $i " "; print s }' +BOARD=$1 +LISTING_HEADING="~~~~~~~~~~~~~~~~~~~" + + +if [ -z "${BOARD}" ]; then + echo "BOARDS" + echo $LISTING_HEADING + ssh $THREADCAT_USER "ls -l /opt/threadcat | grep ^d" | awk '{ s = ""; for (i = 6; i <= 9; i++) s = s $i " "; print s }' + echo "" + echo "TOP LEVEL THREADS" + echo $LISTING_HEADING + ssh $THREADCAT_USER "ls -l /opt/threadcat | grep -v ^d" | awk '{ s = ""; for (i = 6; i <= 9; i++) s = s $i " "; print s }' +else + echo "Listing threads under $BOARD" + echo $LISTING_HEADING + ssh $THREADCAT_USER "ls -lt /opt/threadcat/$BOARD | grep -v ^d" | awk '{ s = ""; for (i = 6; i <= 9; i++) s = s $i " "; print s }' +fi diff --git a/threadcat-read.sh b/threadcat-read.sh index 517f57d..424dc55 100755 --- a/threadcat-read.sh +++ b/threadcat-read.sh @@ -1,11 +1,18 @@ #!/bin/bash -THREAD_NAME=$1 +BOARD_NAME=$1 +THREAD_NAME=$2 + +if [ -z "${THREAD_NAME}" ]; then + THREAD_NAME=$BOARD_NAME +else + THREAD_NAME=$BOARD_NAME/$THREAD_NAME +fi if [ ! -z "${THREAD_NAME}" ]; then ssh $THREADCAT_USER "cat /opt/threadcat/$THREAD_NAME" else echo You did not provide a thread name. - echo USAGE: "threadcat read THREAD_NAME" + echo USAGE: "threadcat read [BOARD] THREAD" fi diff --git a/threadcat-write.sh b/threadcat-write.sh index 81dada2..0e0c09a 100755 --- a/threadcat-write.sh +++ b/threadcat-write.sh @@ -1,15 +1,25 @@ #!/bin/bash -THREAD_NAME=$1 -THREAD_PATH="/opt/threadcat/$THREAD_NAME" +BOARD_NAME=$1 +THREAD_NAME=$2 +THREAD_BOARD_PATH="/opt/threadcat" + +if [ -z "${THREAD_NAME}" ]; then + THREAD_NAME=$BOARD_NAME + BOARD_NAME="" + THREAD_PATH="/opt/threadcat/$THREAD_NAME" +else + THREAD_BOARD_PATH="/opt/threadcat/$BOARD_NAME" + THREAD_PATH="/opt/threadcat/$BOARD_NAME/$THREAD_NAME" +fi if [ ! -z "${THREAD_NAME}" ]; then - cat - | ssh $THREADCAT_USER "umask 002 && echo >> $THREAD_PATH && echo `whoami` -- `date` >> $THREAD_PATH && cat - >> $THREAD_PATH" - echo Posted to $THREAD_NAME + cat - | ssh $THREADCAT_USER "umask 002 && mkdir -p $THREAD_BOARD_PATH && echo >> $THREAD_PATH && echo `whoami` -- `date` >> $THREAD_PATH && cat - >> $THREAD_PATH" + echo "Posted to $BOARD_NAME/$THREAD_NAME" else echo You did not provide a thread name. - echo USAGE: "cat YOURMESSAGE | threadcat write THREAD_NAME" + echo USAGE: "cat YOURMESSAGE | threadcat write [BOARD] THREAD" fi |