termux-api: Remove empty lines from -h output
[termux-packages] / packages / termux-api / termux-dialog
CommitLineData
cc1ae02e 1#!/bin/sh
59f0d218
FF
2set -e -u
3
0ec2b704 4SCRIPTNAME=termux-dialog
59f0d218 5show_usage () {
bea93fbd
FF
6 echo "Usage: $SCRIPTNAME [-i hint] [-m] [-p] [-t title]"
7 echo "Show a text entry dialog."
bea93fbd
FF
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"
bea93fbd 12 exit 0
59f0d218
FF
13}
14
15PARAMS=""
0ec2b704
FF
16
17ARG_I=""
18OPT_I=""
19ARG_M=""
20ARG_P=""
21ARG_T=""
22OPT_T=""
23
24while getopts :hi:mpt: option
25do
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
59f0d218 34done
0ec2b704 35shift $(($OPTIND-1))
59f0d218 36
0ec2b704 37if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
59f0d218 38
8d6e165f
FF
39set -- $ARG_M $ARG_P
40if [ -n "$ARG_I" ]; then set -- "$@" $ARG_I "$OPT_I"; fi
41if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi
42
43@TERMUX_API@ Dialog "$@"