Add --server option to mxc2http
This commit is contained in:
parent
631273bc80
commit
076c72c58e
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user