termux-api: Cleanup and improve consistency
[termux-packages] / packages / termux-api / termux-sms-inbox
CommitLineData
cc1ae02e 1#!/bin/sh
59f0d218
FF
2set -u
3
4PARAM_LIMIT=10
5PARAM_OFFSET=0
6PARAMS=""
7
bea93fbd 8SCRIPTNAME=termux-sms-inbox
59f0d218 9show_usage () {
bea93fbd
FF
10 echo "Usage: termux-sms-inbox [-d] [-l limit] [-n] [-o offset]"
11 echo "List received SMS messages."
12 echo ""
13 echo " -d show dates when messages were created"
14 echo " -l limit offset in sms list (default: $PARAM_LIMIT)"
15 echo " -n show phone numbers"
16 echo " -o offset offset in sms list (default: $PARAM_OFFSET)"
17 echo ""
18 exit 0
59f0d218
FF
19}
20
bea93fbd
FF
21while getopts :hdl:no: option
22do
23 case "$option" in
24 h) show_usage;;
25 d) PARAMS="$PARAMS --ez show-dates true";;
26 l) PARAM_LIMIT=$OPTARG;;
27 n) PARAMS="$PARAMS --ez show-phone-numbers true";;
28 o) PARAM_OFFSET=$OPTARG;;
29 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
30 esac
59f0d218 31done
bea93fbd 32shift $(($OPTIND-1))
59f0d218 33
bea93fbd 34if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
59f0d218
FF
35
36PARAMS="$PARAMS --ei offset $PARAM_OFFSET --ei limit $PARAM_LIMIT"
cc1ae02e 37@TERMUX_API@ SmsInbox $PARAMS