termux-packages/packages/termux-api/termux-download

31 lines
840 B
Plaintext
Raw Normal View History

2015-06-13 01:03:31 +02:00
#!/system/bin/sh
set -e -u
SCRIPTNAME=$0
show_usage () {
echo "usage: termux-download <uri-to-download>"
echo " Download a resource using the system download manager."
echo " -d, --description Description for the download request notification"
echo " -t, --title Title for the download request notification"
}
PARAMS=""
O=`busybox getopt -q -l description: -l title: -l help -- d:t:h "$@"`
if [ $? != 0 ] ; then show_usage; exit 1 ; fi
eval set -- "$O"
while true; do
case "$1" in
-h|--help) show_usage; exit 0;;
-d|--description) PARAMS="$PARAMS --es description '$2'"; shift 2;;
-t|--title) PARAMS="$PARAMS --es title '$2'"; shift 2;;
--) shift; break;;
*) echo Error; exit 1;;
esac
done
# Too many arguments:
if [ $# != 1 ]; then show_usage; exit 1; fi
eval termux-api Download $PARAMS $1