Skip to content

Commit

Permalink
Add QR code flag to goshy
Browse files Browse the repository at this point in the history
This commit adds an additional flag for displaying an QR code as the
respone of running goshy. It requires the qrencode package.

One could check if the depedency exists, but any OS should be able to
report this themselves. So this bloat was not added.
  • Loading branch information
riotbib authored and oxzi committed Sep 15, 2024
1 parent 559c069 commit b4997cb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions contrib/bash/goshy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Options:
-i --instance Complete URL to the gosh instance.
-p --period TIMEFRAME Set a custom expiry period.
-u --only-url Print only URL as response.
-q --qr-code Print only QR code as response.
EOF
}

Expand Down Expand Up @@ -37,6 +38,10 @@ while :; do
ONLYURL="1"
;;

-q|--qr-code)
QRCODE="1"
;;

*)
FILE=$1
break
Expand All @@ -55,16 +60,18 @@ if [ -z "$GOSH_INSTANCE" ]; then
exit 1
fi

CURL_CMD="curl -F 'file=@${FILE}'"
CURL_CMD="curl -s -F 'file=@${FILE}'"
if [[ -n ${BURN+x} ]]; then
CURL_CMD="${CURL_CMD} -F 'burn=1'"
fi
if [[ -n ${PERIOD+x} ]]; then
CURL_CMD="${CURL_CMD} -F 'time=${PERIOD}'"
fi
CURL_CMD="${CURL_CMD} ${GOSH_INSTANCE}"
if [[ -n ${ONLYURL+x} ]]; then
if [[ -n ${ONLYURL+x} ]] || [[ -n ${QRCODE+x} ]]; then
CURL_CMD="${CURL_CMD}/?onlyURL"
fi

if [[ -n ${QRCODE+x} ]]; then
CURL_CMD="${CURL_CMD} | qrencode -t UTF8"
fi
eval "$CURL_CMD"

0 comments on commit b4997cb

Please sign in to comment.