Beginnings of the command parser added.
This commit is contained in:
parent
ebad002e73
commit
ae0cc60a79
37
ratatoskr.sh
37
ratatoskr.sh
@ -3,6 +3,15 @@
|
||||
# Hopefully one day this will be a full featured Pleroma client.
|
||||
# Let's see how far we can get. :)
|
||||
|
||||
# Handle subprocesses that may not close with the main program.
|
||||
trap cleanup EXIT
|
||||
cleanup() {
|
||||
if [[ $bgLoop -ne 0 ]]; then
|
||||
trap 'pkill -P $$' EXIT
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Display usage information.
|
||||
help() {
|
||||
echo "${0##*/}"
|
||||
@ -181,6 +190,9 @@ done
|
||||
# make sure the configuration and soundpack paths exist:
|
||||
mkdir -p "${configPath}/soundpacks"
|
||||
|
||||
# Keep track of the backgrounded loop
|
||||
bgLoop=0
|
||||
|
||||
# Associative array of command line parameters and short description of what they do.
|
||||
declare -A command=(
|
||||
[C]="Recreate default configuration file. Acquire new oauth token."
|
||||
@ -219,8 +231,11 @@ while getopts "${args}" i ; do
|
||||
done
|
||||
|
||||
|
||||
# Main loop
|
||||
# Main loops
|
||||
# Display timelines and requested information.
|
||||
while : ; do
|
||||
# Important, set bgLoop to 1 or this loop will not close with the program
|
||||
bgLoop=1
|
||||
if [[ -n "${since_id}" ]]; then
|
||||
result="$(curl -sS --oauth2-bearer "${oauth_token}" "${instanceURL}/api/va/timelines/${timeline:-home}?since_id=${since_id}")"
|
||||
else
|
||||
@ -257,6 +272,26 @@ while : ; do
|
||||
fi
|
||||
|
||||
sleep "${interval:-300}"
|
||||
done &
|
||||
|
||||
|
||||
# Handle commands
|
||||
while : ; do
|
||||
# Command prompt:
|
||||
read -er -p "<${softwareName}> " command
|
||||
if [[ ! "${command}" =~ ^/ ]]; then
|
||||
post_status "${command}"
|
||||
continue
|
||||
fi
|
||||
case "${command}" in
|
||||
"/exit"|"/quit")
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
systemMessage="Error: '${command}' is not a valid command."
|
||||
play_sound error
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user