Files
mlbstats-mastodon-scripts/plays/mlbplaypost.sh

36 lines
567 B
Bash
Raw Normal View History

2024-07-24 21:17:36 -05:00
#!/bin/bash
2024-07-25 22:34:35 -05:00
set -e
2024-07-30 20:05:02 -05:00
while getopts 'd:a:' opt
2024-07-26 19:14:39 -05:00
do
case $opt in
d)
db=$OPTARG
;;
2024-07-30 20:05:02 -05:00
a)
account=$OPTARG
;;
2024-07-26 19:14:39 -05:00
?)
exit 1
;;
esac
done
if [[ -z $db ]]
2024-07-25 22:48:57 -05:00
then
2024-07-26 19:14:39 -05:00
echo "$0:" '-d is required' >&2
2024-07-25 22:48:57 -05:00
exit 1
fi
2024-07-30 20:05:02 -05:00
if [[ -z $account ]]
then
echo "$0:" '-a is required' >&2
exit 1
fi
2024-07-31 21:42:56 -05:00
# format each row of data retreived from the select statement and pipe to toot
2024-07-30 20:05:02 -05:00
fmt='printf "%s\n\n%s %s\n#%s %s\n#%s %s\n\n#baseball #live\n", $1, $2, $3, $4, $5, $6, $7'
2024-08-01 18:29:44 -05:00
post="\"toot post --using $account\""
sqlite3 $db < postplays.sql | awk -F  "{$fmt | $post; close($post)}"