Commit | Line | Data |
---|---|---|
cc1ae02e | 1 | #!/bin/sh |
59f0d218 FF |
2 | set -e -u |
3 | ||
0ec2b704 | 4 | SCRIPTNAME=termux-dialog |
59f0d218 | 5 | show_usage () { |
bea93fbd FF |
6 | echo "Usage: $SCRIPTNAME [-i hint] [-m] [-p] [-t title]" |
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 | echo "" | |
14 | exit 0 | |
59f0d218 FF |
15 | } |
16 | ||
17 | PARAMS="" | |
0ec2b704 FF |
18 | |
19 | ARG_I="" | |
20 | OPT_I="" | |
21 | ARG_M="" | |
22 | ARG_P="" | |
23 | ARG_T="" | |
24 | OPT_T="" | |
25 | ||
26 | while getopts :hi:mpt: option | |
27 | do | |
28 | case "$option" in | |
29 | h) show_usage;; | |
30 | i) ARG_I="--es input_hint"; OPT_I="$OPTARG";; | |
31 | m) ARG_M="--ez multiple_lines true";; | |
32 | p) ARG_P="--es input_type password";; | |
33 | t) ARG_T="--es input_title"; OPT_T="$OPTARG";; | |
34 | ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; | |
35 | esac | |
59f0d218 | 36 | done |
0ec2b704 | 37 | shift $(($OPTIND-1)) |
59f0d218 | 38 | |
0ec2b704 | 39 | if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi |
59f0d218 | 40 | |
8d6e165f FF |
41 | set -- $ARG_M $ARG_P |
42 | if [ -n "$ARG_I" ]; then set -- "$@" $ARG_I "$OPT_I"; fi | |
43 | if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi | |
44 | ||
45 | @TERMUX_API@ Dialog "$@" |