#!/bin/bash
host=https://midnight.pub
if [ $# -eq 0 ]
then
curl -F title="$(head -1 /dev/stdin)"\
-F content="$(tail -n +2 /dev/stdin)"\
-b midn="$(cat ~/.config/.midnight)"\
$host/posts/save
fi
while getopts "r:t:" OPTION; do
case $OPTION in
r)
curl -F reply="$(cat /dev/stdin)"\
-b midn="$(cat ~/.config/.midnight)"\
$host/posts/$OPTARG/reply
;;
t)
curl -F reply="$(cat /dev/stdin)"\
-b midn="$(cat ~/.config/.midnight)"\
$host/replies/$OPTARG/save
;;
*)
echo "Incorrect options provided"
exit 1
;;
esac
done