termux-api: Start to cleanup api calling scripts
[termux-packages] / packages / termux-api / termux-dialog
1 #!/bin/sh
2 set -e -u
3
4 SCRIPTNAME=termux-dialog
5 show_usage () {
6 echo "Usage: $SCRIPTNAME [OPTIONS]"
7 echo "Show a text entry dialog."
8 echo ""
9 echo " -i <hint> The input hint to show when the input is empty"
10 echo " -m Use a textarea with multiple lines instead of a single"
11 echo " -p Enter the input as a password"
12 echo " -t <title> The title to show for the input prompt"
13 exit 0
14 }
15
16 PARAMS=""
17
18 ARG_I=""
19 OPT_I=""
20 ARG_M=""
21 ARG_P=""
22 ARG_T=""
23 OPT_T=""
24
25 while getopts :hi:mpt: option
26 do
27 case "$option" in
28 h) show_usage;;
29 i) ARG_I="--es input_hint"; OPT_I="$OPTARG";;
30 m) ARG_M="--ez multiple_lines true";;
31 p) ARG_P="--es input_type password";;
32 t) ARG_T="--es input_title"; OPT_T="$OPTARG";;
33 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
34 esac
35 done
36 shift $(($OPTIND-1))
37
38 if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
39
40 @TERMUX_API@ Dialog $ARG_I "$OPT_I" $ARG_M $ARG_P $ARG_T "$OPT_T"