Commit | Line | Data |
---|---|---|
59f0d218 FF |
1 | #!/system/bin/sh |
2 | set -e -u | |
3 | ||
4 | PARAMS="" | |
5 | show_usage () { | |
6 | echo "usage: termux-location [OPTIONS]" | |
7 | echo "Get the device location. Options:" | |
8 | echo " -r, --request kind of request(s) to make [once/last/updates] (default: once)" | |
9 | echo " -p, --provider location provider [gps/network/passive] (default: gps)" | |
10 | } | |
11 | ||
12 | O=`busybox getopt -q -l request: -l provider: -- r:hp: "$@"` | |
13 | if [ $? != 0 ] ; then show_usage; exit 1 ; fi | |
14 | eval set -- "$O" | |
15 | while true; do | |
16 | case "$1" in | |
17 | -h|--help) show_usage; exit 0;; | |
18 | -r|--request) PARAMS="$PARAMS --es request $2"; shift 2;; | |
19 | -p|--provider) PARAMS="$PARAMS --es provider $2"; shift 2;; | |
20 | --) shift; break;; | |
21 | *) echo Error; show_usage; exit 1;; | |
22 | esac | |
23 | done | |
24 | ||
25 | # Too many arguments: | |
26 | if [ $# != 0 ]; then show_usage; exit 1; fi | |
27 | ||
28 | termux-api Location $PARAMS |