2015-08-14 21:27:47 +02:00
|
|
|
#!/bin/sh
|
2015-06-13 01:03:31 +02:00
|
|
|
set -e -u
|
|
|
|
|
|
|
|
PARAMS=""
|
|
|
|
show_usage () {
|
|
|
|
echo "usage: termux-location [OPTIONS]"
|
|
|
|
echo "Get the device location. Options:"
|
|
|
|
echo " -r, --request kind of request(s) to make [once/last/updates] (default: once)"
|
|
|
|
echo " -p, --provider location provider [gps/network/passive] (default: gps)"
|
|
|
|
}
|
|
|
|
|
|
|
|
O=`busybox getopt -q -l request: -l provider: -- r:hp: "$@"`
|
|
|
|
if [ $? != 0 ] ; then show_usage; exit 1 ; fi
|
|
|
|
eval set -- "$O"
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
-h|--help) show_usage; exit 0;;
|
|
|
|
-r|--request) PARAMS="$PARAMS --es request $2"; shift 2;;
|
|
|
|
-p|--provider) PARAMS="$PARAMS --es provider $2"; shift 2;;
|
|
|
|
--) shift; break;;
|
|
|
|
*) echo Error; show_usage; exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# Too many arguments:
|
|
|
|
if [ $# != 0 ]; then show_usage; exit 1; fi
|
|
|
|
|
2015-08-14 21:27:47 +02:00
|
|
|
@TERMUX_API@ Location $PARAMS
|