chiark / gitweb /
640edd1679fc7386051a286c95e06bdabfbb2e43
[termux-packages] / packages / termux-api / termux-dialog
1 #!/bin/sh
2
3 set -e -u
4
5 SCRIPTNAME=$0
6 show_usage () {
7         echo "usage: $SCRIPTNAME [OPTIONS]"
8         echo "       Show a text entry dialog."
9         echo "       -i, --input-hint <hint>   The input hint to show when the input is empty"
10         echo "       -p, --password            Enter the input as a password"
11 }
12
13 PARAMS=""
14 O=`busybox getopt -q -l help -l input-hint: -l password -- hi:p "$@"`
15 if [ $? != 0 ] ; then show_usage; exit 1 ; fi
16 eval set -- "$O"
17 while true; do
18 case "$1" in
19         -h|--help) show_usage; exit 0;;
20         -i|--input-hint) PARAMS="$PARAMS --es input_hint '$2'"; shift 2;;
21         -p|--password) PARAMS="$PARAMS --es input_type password"; shift 1;;
22         --)     shift; break;;
23         *)      echo Error; exit 1;;
24 esac
25 done
26
27 # Too many arguments:
28 if [ $# != 0 ]; then show_usage; exit 1; fi
29
30 eval @TERMUX_API@ Dialog $PARAMS