termux-packages/packages/termux-api/termux-dialog
Fredrik Fornwall 0ec2b70462 termux-api: Start to cleanup api calling scripts
Start using shell built-in getops and remove long arguments.

Make both clipboard-set and sms-send either take argument or read
from stdin.  Fixes https://github.com/termux/termux-api/issues/14
2016-04-19 16:35:23 +02:00

41 lines
956 B
Bash
Executable File

#!/bin/sh
set -e -u
SCRIPTNAME=termux-dialog
show_usage () {
echo "Usage: $SCRIPTNAME [OPTIONS]"
echo "Show a text entry dialog."
echo ""
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
}
PARAMS=""
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
done
shift $(($OPTIND-1))
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
@TERMUX_API@ Dialog $ARG_I "$OPT_I" $ARG_M $ARG_P $ARG_T "$OPT_T"