Add --server option to mxc2http

This commit is contained in:
tastytea 2022-04-16 15:28:13 +02:00
parent 631273bc80
commit 076c72c58e
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
2 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,8 @@
#compdef mxc2http
_arguments '-h[short help text]' '*:url:_urls'
_arguments '-h[short help text]' \
'--server[server to use as host]:server:' \
'*:url:_urls'
# Local Variables:
# mode: shell-script

View File

@ -5,7 +5,8 @@ setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
zmodload zsh/zutil
local -a o_help=()
zparseopts -D -K -- h=o_help
local -a o_server=()
zparseopts -D -K -- h=o_help -server:=o_server
if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then
ret=$(( ${#o_help} ^ 1 ))
print -u $(( 1 + ${ret} )) "usage: ${0} [-h] <URL> …"
@ -15,7 +16,9 @@ local -a urls=(${@})
for url in ${urls}; do
local domain=${${url%/*}##*/}
local server=${domain}
[[ ${#o_server} -eq 2 ]] && server=${o_server[2]}
local id=${url##*/}
print '\e[1;95m→\e[0m' \
"https://${domain}/_matrix/media/r0/download/${domain}/${id}"
"https://${server}/_matrix/media/r0/download/${domain}/${id}"
done