twtxt-c/twtxt-c

56 lines
1.8 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
PROGNAME=${0##*/}
VERSION="0.0.1"
error_exit() {
printf "%s: %s\n" "$PROGNAME" "${1:-"Unknown Error"}" >&2
exit 1
}
usage() {
printf "usage: %s [OPTIONS] COMMAND [ARGS]\n" "$PROGNAME"
printf "Simple client for twtxt\n"
printf "Options:\n
-c, --config PATH Specify a custom config file location.
-v, --verbose Enable verbose output for debugging purposes.
--version Show the version and exit.
-h, --help Show this message and exit.
Commands:
init Setting up twtxt.
config Get or set config item.
follow Add a new source to your followings.
following Return the list of sources youre following.
timeline Retrieve your personal timeline.
tweet Append a new tweet to your twtxt file.
unfollow Remove an existing source from your...
view Show feed of given source.
registry Show registers\n"
}
case $1 in
-h | --help)
usage; exit ;;
-* | --*)
usage; error_exit "unknown option $1" ;;
init)
read -p "Your desired nickname [$USER]: " nick
nick=${nick:-"$USER"}
read -p "Type path to your twtxt [/home/$USER/twtxt.txt]: " path_to_twtxt
path_to_twtxt=${path_to_twtxt:-"/home/$USER/twtxt.txt"}
echo "" >> $path_to_twtxt
read -p "Type path to your twtxt config folder [/home/$USER/.config/twtxt-c/]: " config
config=${config:-"/home/$USER/.config/twtxt-c/"}
mkdir -p $config
read -p "URL to twtxt [https://example.com/twtxt.txt]: " url
url=${url:-"https://example.com/twtxt.txt"}
printf "[twtxt]\n nick = %s\n twtfile = %s\n url = %s\n" "$nick" "$path_to_twtxt" "$url" >> $config/config
;;
tweet)
export config=/home/$USER/.config/twtxt-c/config
printf "%s\t%s\n" "$(date +'%FT%T%:z')" "$2" >> $(awk '/twtfile/ {print $3}' $config)
;;
*)
printf "Work in progress\n" ;;
esac