mirror of
https://github.com/notwa/rc
synced 2024-11-14 13:59:02 -08:00
50 lines
1.2 KiB
Bash
Executable file
50 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env sh
|
|
# remote file access (http file-sharing shenanigans)
|
|
# YES_ZSH
|
|
# YES_BASH
|
|
# YES_DASH
|
|
# YES_ASH
|
|
|
|
ea() { ### @- **TODO:** document.
|
|
local cmd="${1:?missing subcommand}"; shift
|
|
case "$cmd" in
|
|
head)
|
|
local trg="$EA_DOMAIN/$EA_DIR/${1:?missing target}"
|
|
curl -s -I "$trg"
|
|
return;;
|
|
|
|
get)
|
|
local trg="$EA_DOMAIN/$EA_DIR/${1:?missing target}"
|
|
curl -R "$trg" -o "${2:-$1}"
|
|
return;;
|
|
|
|
put)
|
|
local src="${1:?missing source}"
|
|
local dst="$EA_DOMAIN/$EA_AUTH/"
|
|
curl -g -n -T "$src" "$dst"
|
|
return;;
|
|
|
|
move)
|
|
local src="$EA_DOMAIN/$EA_AUTH/${1:?missing source}"
|
|
local dst="$EA_DOMAIN/$EA_DIR/${2:?missing destination}"
|
|
curl -n -X MOVE -H "Destination: $dst" "$src"
|
|
return;;
|
|
|
|
copy)
|
|
local src="$EA_DOMAIN/$EA_AUTH/${1:?missing source}"
|
|
local dst="$EA_DOMAIN/$EA_DIR/${2:?missing destination}"
|
|
curl -n -X COPY -H "Destination: $dst" "$src"
|
|
return;;
|
|
|
|
delete)
|
|
local trg="$EA_DOMAIN/$EA_AUTH/${1:?missing target}"
|
|
curl -f -n -X DELETE "$trg"
|
|
return;;
|
|
|
|
*)
|
|
printf 'unknown subcommand: %s\n' "$1" >&2
|
|
return 2;;
|
|
esac
|
|
}
|
|
|
|
[ -n "${preload+-}" ] || ea "$@"
|