19 lines
565 B
Fish
19 lines
565 B
Fish
function http --argument-names method url --description "Curl wrapper with cache options"
|
|
|
|
argparse h/help c/cache '#cache_time' -- $argv
|
|
or return
|
|
|
|
# If -h or --help is given, we print a little help text and return
|
|
if set -ql _flag_help
|
|
echo "http [-h|--help] [-s|--second] METHOD URL"
|
|
return 0
|
|
end
|
|
|
|
if set -ql _flag_cache
|
|
mkdir -p /tmp/fish_http
|
|
|
|
curl -SsL -X (string upper $method) $url | tee /tmp/fish_http/(string escape --style=url $url)
|
|
else
|
|
curl -X (string upper $method) $url
|
|
end
|
|
end
|