Added -r flag
This commit is contained in:
parent
2888cb0faf
commit
020654d509
|
@ -8,18 +8,22 @@ help() {
|
|||
echo " Arguments:"
|
||||
echo " -d Checks if the Publication Date of the post is Today."
|
||||
echo " If not, it exits."
|
||||
echo " -r Uses a random expression. Possibly funny."
|
||||
echo " -t Post the link with toot. A prompt will ask confirmation."
|
||||
echo " Accepted value: direct, unlisted, public, private"
|
||||
echo " -h Displays this message."
|
||||
echo ""
|
||||
}
|
||||
|
||||
while getopts ":dt:h" opt; do
|
||||
while getopts ":drt:h" opt; do
|
||||
case $opt in
|
||||
d)
|
||||
TODAY=$(date +'%d %b %Y')
|
||||
CHECK_TODAY=1
|
||||
;;
|
||||
r)
|
||||
RANDOMIZE=1
|
||||
;;
|
||||
t)
|
||||
TOOT=1
|
||||
case "${OPTARG}" in
|
||||
|
@ -61,11 +65,32 @@ today() {
|
|||
fi
|
||||
}
|
||||
|
||||
random() {
|
||||
EXPRESSIONS=("Latest article on my blog:"
|
||||
"Latest rant on my blog:"
|
||||
"Check out my latest post!"
|
||||
"New. Blog. Post. NOW!"
|
||||
"Just wrote a new blog post:"
|
||||
"Just hit some random keys on the keyboard and pressed \"Publish\":"
|
||||
"Just hit some random keys on my keyboard:"
|
||||
"New thoughts:"
|
||||
"New wordvomit:"
|
||||
"I could have used some cool app to publish this post. Instead I used a script."
|
||||
"100 PRINT \"NEW BLOG POST\"\n200 PRINT"
|
||||
"Yet another article on my blog."
|
||||
"This is a random sentence chosen by a Bash script. Sorry if it doesn't make much sense."
|
||||
"Roses are red. Violets are blue. Here is a new blog post:"
|
||||
"Sit down, grab a cup of tea, and click here for a new article on my blog:"
|
||||
"🧠 -> 🧑💻 ->"
|
||||
"$ cat new_blog_post.md\n")
|
||||
EXPRESSION=${EXPRESSIONS[ $RANDOM % ${#EXPRESSIONS[@]} ]}
|
||||
}
|
||||
|
||||
yes_or_no() {
|
||||
while true; do
|
||||
read -p "$* [y/n]: " yn
|
||||
case $yn in
|
||||
[Yy]*) echo "Latest article from my blog: \"$TITLE\"\n\n$LINK" | \
|
||||
[Yy]*) echo "$EXPRESSION \"$TITLE\"\n\n$LINK" | \
|
||||
/opt/homebrew/bin/toot post -v $VISIBILITY ; return 0 ;;
|
||||
[Nn]*) echo "Exiting." ; cleanup 0 ;;
|
||||
esac
|
||||
|
@ -106,8 +131,11 @@ PUB_DATE=$(sed -n "/<link>$LINK_FIXED/,/pubDate/p" feed.xml | tail -n 1 | sed 's
|
|||
|
||||
if [[ "$CHECK_TODAY" == "1" ]]; then today; fi
|
||||
|
||||
EXPRESSION="Latest article on my blog:"
|
||||
if [[ "$RANDOMIZE" == "1" ]]; then random; fi
|
||||
|
||||
echo "\nCopy and Paste this:\n\n+++++"
|
||||
echo "Latest article from my blog: \"$TITLE\"\n\n$LINK"
|
||||
echo "$EXPRESSION \"$TITLE\"\n\n$LINK"
|
||||
echo "+++++\n"
|
||||
|
||||
if [[ "$TOOT" == "1" ]]; then
|
||||
|
|
Loading…
Reference in New Issue