Update SDK build tools to 24.0.1
[termux-packages] / packages / termux-api / termux-download
CommitLineData
cc1ae02e 1#!/bin/sh
59f0d218
FF
2set -e -u
3
8d6e165f 4SCRIPTNAME=termux-download
59f0d218 5show_usage () {
bea93fbd
FF
6 echo "Usage: $SCRIPTNAME [-d description] [-t title] url-to-download"
7 echo "Download a resource using the system download manager."
8 echo ""
9 echo " -d description description for the download request notification"
10 echo " -t title title for the download request notification"
11 echo ""
12 exit 0
59f0d218
FF
13}
14
8d6e165f
FF
15ARG_D=""
16OPT_D=""
17ARG_T=""
18OPT_T=""
19
20while getopts :hd:t: option
21do
22 case "$option" in
23 h) show_usage;;
24 d) ARG_D="--es description"; OPT_D="$OPTARG";;
25 t) ARG_T="--es title"; OPT_T="$OPTARG";;
26 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
27 esac
59f0d218 28done
8d6e165f
FF
29shift $(($OPTIND-1))
30
31if [ $# -lt 1 ]; then echo "$SCRIPTNAME: no url specified"; exit 1; fi
32if [ $# -gt 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
33
34URL_TO_DOWNLOAD="$1"
59f0d218 35
8d6e165f
FF
36set --
37if [ -n "$ARG_D" ]; then set -- "$@" $ARG_D "$OPT_D"; fi
38if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi
39set -- "$@" $URL_TO_DOWNLOAD
59f0d218 40
8d6e165f 41@TERMUX_API@ Download "$@"