Initial push
[termux-packages] / packages / termux-api / termux-download
1 #!/system/bin/sh
2
3 set -e -u
4
5 SCRIPTNAME=$0
6 show_usage () {
7 echo "usage: termux-download <uri-to-download>"
8 echo " Download a resource using the system download manager."
9 echo " -d, --description Description for the download request notification"
10 echo " -t, --title Title for the download request notification"
11 }
12
13 PARAMS=""
14 O=`busybox getopt -q -l description: -l title: -l help -- d:t:h "$@"`
15 if [ $? != 0 ] ; then show_usage; exit 1 ; fi
16 eval set -- "$O"
17 while true; do
18 case "$1" in
19 -h|--help) show_usage; exit 0;;
20 -d|--description) PARAMS="$PARAMS --es description '$2'"; shift 2;;
21 -t|--title) PARAMS="$PARAMS --es title '$2'"; shift 2;;
22 --) shift; break;;
23 *) echo Error; exit 1;;
24 esac
25 done
26
27 # Too many arguments:
28 if [ $# != 1 ]; then show_usage; exit 1; fi
29
30 eval termux-api Download $PARAMS $1