Commit | Line | Data |
---|---|---|
59f0d218 FF |
1 | #!/system/bin/sh |
2 | set -u | |
3 | ||
4 | PARAM_LIMIT=10 | |
5 | PARAM_OFFSET=0 | |
6 | PARAMS="" | |
7 | ||
8 | SCRIPTNAME=$0 | |
9 | show_usage () { | |
10 | echo "usage: termux-sms-inbox [OPTIONS]" | |
11 | echo "List received SMS messages." | |
12 | echo "" | |
13 | echo "Options are all optional." | |
14 | echo " -d, --show-dates show dates" | |
15 | echo " -n, --show-phone-numbers show phone numbers" | |
16 | echo " -o, --offset offset in sms list (default: $PARAM_OFFSET)" | |
17 | echo " -l, --limit offset in sms list (default: $PARAM_LIMIT)" | |
18 | } | |
19 | ||
20 | O=`busybox getopt -q -l help -l show-dates -l show-phone-numbers -l limit: -l offset: -- dhl:no: "$@"` | |
21 | if [ $? != 0 ] ; then show_usage; exit 1 ; fi | |
22 | eval set -- "$O" | |
23 | while true; do | |
24 | case "$1" in | |
25 | -h|--help) show_usage; exit 0;; | |
26 | -l|--limit) PARAM_LIMIT=$2; shift 2;; | |
27 | -o|--offset) PARAM_OFFSET=$2; shift 2;; | |
28 | -d|--show-dates) PARAMS="$PARAMS --ez show-dates true"; shift;; | |
29 | -n|--show-phone-numbers) PARAMS="$PARAMS --ez show-phone-numbers true"; shift;; | |
30 | --) shift; break;; | |
31 | *) echo Error; exit 1;; | |
32 | esac | |
33 | done | |
34 | ||
35 | # Too many arguments: | |
36 | if [ $# != 0 ]; then show_usage; exit 1; fi | |
37 | ||
38 | PARAMS="$PARAMS --ei offset $PARAM_OFFSET --ei limit $PARAM_LIMIT" | |
39 | ||
40 | termux-api SmsInbox $PARAMS |