Content: Replaced custom spinner with curl command and removed unnecessary code for setting up spinner.

This commit is contained in:
ilguappo 2024-08-07 04:33:31 -07:00
parent 7de04c06c9
commit e0ee195fca

View File

@ -29,18 +29,6 @@ hasFlag() {
echo 'false' echo 'false'
} }
spin() {
echo "${@}"
while true; do
spinner=('-' '\' '|' '/')
for i in "${spinner[@]}"; do
echo -ne "\r${i}"
sleep .05
done
done
echo ""
}
if ! diff=$(git diff --cached); then if ! diff=$(git diff --cached); then
echo "Failed to get diff." echo "Failed to get diff."
exit 1 exit 1
@ -56,18 +44,13 @@ message=$(
# trunk-ignore(shellcheck/SC2091) # trunk-ignore(shellcheck/SC2091)
# trunk-ignore(shellcheck/SC2310) # trunk-ignore(shellcheck/SC2310)
if $(hasFlag -r --reset); then if $(hasFlag -r --reset); then
spin "resetting AI history." &
SPINNER="$!"
if ! curl -s -X POST https://infer.x64.world/reset-conversation >/dev/null; then if ! curl -s -X POST https://infer.x64.world/reset-conversation >/dev/null; then
echo "Failed to reset conversation." echo "Failed to reset conversation."
kill ${SPINNER}
exit 1 exit 1
fi fi
kill "${SPINNER}"
fi fi
spin "AI is thinking." &
SPINNER="$!"
curl -s "https://infer.x64.world/chat" \ curl -s "https://infer.x64.world/chat" \
-X POST \ -X POST \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
@ -75,11 +58,9 @@ curl -s "https://infer.x64.world/chat" \
# trunk-ignore(shellcheck/SC2181) # trunk-ignore(shellcheck/SC2181)
if [[ 0 -ne $? ]]; then if [[ 0 -ne $? ]]; then
kill "${SPINNER}"
echo "Failed to get response." echo "Failed to get response."
exit 1 exit 1
fi fi
kill "${SPINNER}"
git commit -e -m "$(cat "${TMP_FILE}")" && rm "${TMP_FILE}" git commit -e -m "$(cat "${TMP_FILE}")" && rm "${TMP_FILE}"