2015-08-14 21:27:47 +02:00
|
|
|
#!/bin/sh
|
2015-06-13 01:03:31 +02:00
|
|
|
set -e -u
|
|
|
|
|
2016-04-19 16:34:01 +02:00
|
|
|
SCRIPTNAME=termux-dialog
|
2015-06-13 01:03:31 +02:00
|
|
|
show_usage () {
|
2016-04-26 01:37:45 +02:00
|
|
|
echo "Usage: $SCRIPTNAME [-i hint] [-m] [-p] [-t title]"
|
|
|
|
echo "Show a text entry dialog."
|
|
|
|
echo " -i hint the input hint to show when the input is empty"
|
|
|
|
echo " -m use a textarea with multiple lines instead of a single"
|
|
|
|
echo " -p enter the input as a password"
|
|
|
|
echo " -t title the title to show for the input prompt"
|
|
|
|
exit 0
|
2015-06-13 01:03:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PARAMS=""
|
2016-04-19 16:34:01 +02:00
|
|
|
|
|
|
|
ARG_I=""
|
|
|
|
OPT_I=""
|
|
|
|
ARG_M=""
|
|
|
|
ARG_P=""
|
|
|
|
ARG_T=""
|
|
|
|
OPT_T=""
|
|
|
|
|
|
|
|
while getopts :hi:mpt: option
|
|
|
|
do
|
|
|
|
case "$option" in
|
|
|
|
h) show_usage;;
|
|
|
|
i) ARG_I="--es input_hint"; OPT_I="$OPTARG";;
|
|
|
|
m) ARG_M="--ez multiple_lines true";;
|
|
|
|
p) ARG_P="--es input_type password";;
|
|
|
|
t) ARG_T="--es input_title"; OPT_T="$OPTARG";;
|
|
|
|
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
|
|
|
|
esac
|
2015-06-13 01:03:31 +02:00
|
|
|
done
|
2016-04-19 16:34:01 +02:00
|
|
|
shift $(($OPTIND-1))
|
2015-06-13 01:03:31 +02:00
|
|
|
|
2016-04-19 16:34:01 +02:00
|
|
|
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
|
2015-06-13 01:03:31 +02:00
|
|
|
|
2016-04-20 11:34:03 +02:00
|
|
|
set -- $ARG_M $ARG_P
|
|
|
|
if [ -n "$ARG_I" ]; then set -- "$@" $ARG_I "$OPT_I"; fi
|
|
|
|
if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi
|
|
|
|
|
|
|
|
@TERMUX_API@ Dialog "$@"
|