Update README.md
[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 [-i hint] [-m] [-p] [-t title]"
7 echo "Show a text entry dialog."
8 echo " -i hint the input hint to show when the input is empty"
9 echo " -m use a textarea with multiple lines instead of a single"
10 echo " -p enter the input as a password"
11 echo " -t title the title to show for the input prompt"
12 exit 0
13 }
14
15 PARAMS=""
16
17 ARG_I=""
18 OPT_I=""
19 ARG_M=""
20 ARG_P=""
21 ARG_T=""
22 OPT_T=""
23
24 while getopts :hi:mpt: option
25 do
26 case "$option" in
27 h) show_usage;;
28 i) ARG_I="--es input_hint"; OPT_I="$OPTARG";;
29 m) ARG_M="--ez multiple_lines true";;
30 p) ARG_P="--es input_type password";;
31 t) ARG_T="--es input_title"; OPT_T="$OPTARG";;
32 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
33 esac
34 done
35 shift $(($OPTIND-1))
36
37 if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
38
39 set -- $ARG_M $ARG_P
40 if [ -n "$ARG_I" ]; then set -- "$@" $ARG_I "$OPT_I"; fi
41 if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi
42
43 @TERMUX_API@ Dialog "$@"