Merge pull request #30 from Epictek/master

Date Format option
This commit is contained in:
Fredrik Fornwall 2018-08-26 01:13:19 +02:00 committed by GitHub
commit f6af4611c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,7 @@ OPT_NUMERIC_DESC="[-n] enter input as numbers (optional)"
OPT_TITLE_DESC="[-t title] set title of dialog (optional)" OPT_TITLE_DESC="[-t title] set title of dialog (optional)"
OPT_RANGE_DESC="[-r min,max,start] comma delim of (3) numbers to use (optional)" OPT_RANGE_DESC="[-r min,max,start] comma delim of (3) numbers to use (optional)"
OPT_VALUES_DESC="[-v \",,,\"] comma delim values to use (required)" OPT_VALUES_DESC="[-v \",,,\"] comma delim values to use (required)"
OPT_DATEFORMAT_DESC="[-d \"dd-MM-yyyy k:m:s\"] SimpleDateFormat Pattern for date widget output (optional)"
# Widget hints # Widget hints
ARG_I="" ARG_I=""
@ -52,6 +53,10 @@ OPT_T=""
OPT_V="" OPT_V=""
ARG_V="" ARG_V=""
# Date output format (supported by date widget)
ARG_D=""
OPT_D=""
# Widget type # Widget type
ARG_W="" ARG_W=""
WIDGET="" WIDGET=""
@ -90,6 +95,7 @@ widget_usage () {
"date") "date")
echo "Pick a date" echo "Pick a date"
echo " $OPT_TITLE_DESC" echo " $OPT_TITLE_DESC"
echo " $OPT_DATEFORMAT_DESC"
;; ;;
"radio") "radio")
echo "Pick a single value from radio buttons" echo "Pick a single value from radio buttons"
@ -156,7 +162,7 @@ set_flag () {
# Convenience method to get all supported options, regardless of specified widget # Convenience method to get all supported options, regardless of specified widget
# NOTE: Option combination validation doesn't occur here # NOTE: Option combination validation doesn't occur here
parse_options() { parse_options() {
while getopts :hlmnpr:i:t:v: option while getopts :hlmnpr:i:t:d:v: option
do do
case "$option" in case "$option" in
h) show_usage ;; h) show_usage ;;
@ -166,6 +172,7 @@ parse_options() {
p) ARG_P="--ez password"; OPT_P="true"; set_flag $PASS_FLAG; ;; p) ARG_P="--ez password"; OPT_P="true"; set_flag $PASS_FLAG; ;;
n) ARG_N="--ez numeric"; OPT_N="true"; set_flag $NUM_FLAG; ;; n) ARG_N="--ez numeric"; OPT_N="true"; set_flag $NUM_FLAG; ;;
t) ARG_T="--es input_title"; OPT_T="$OPTARG" ;; t) ARG_T="--es input_title"; OPT_T="$OPTARG" ;;
d) ARG_D="--es date_format"; OPT_D="$OPTARG";;
v) ARG_V="--es input_values"; OPT_V="$OPTARG"; set_flag $VALUES_FLAG; ;; v) ARG_V="--es input_values"; OPT_V="$OPTARG"; set_flag $VALUES_FLAG; ;;
r) ARG_R="--eia input_range"; OPT_R=$OPTARG; set_flag $RANGE_FLAG; ;; r) ARG_R="--eia input_range"; OPT_R=$OPTARG; set_flag $RANGE_FLAG; ;;
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
@ -268,5 +275,6 @@ if [ -n "$ARG_V" ]; then set -- "$@" $ARG_V "$OPT_V"; fi
if [ -n "$ARG_M" ]; then set -- "$@" $ARG_M "$OPT_M"; fi if [ -n "$ARG_M" ]; then set -- "$@" $ARG_M "$OPT_M"; fi
if [ -n "$ARG_P" ]; then set -- "$@" $ARG_P "$OPT_P"; fi if [ -n "$ARG_P" ]; then set -- "$@" $ARG_P "$OPT_P"; fi
if [ -n "$ARG_N" ]; then set -- "$@" $ARG_N "$OPT_N"; fi if [ -n "$ARG_N" ]; then set -- "$@" $ARG_N "$OPT_N"; fi
if [ -n "$ARG_D" ]; then set -- "$@" $ARG_D "$OPT_D"; fi
/data/data/com.termux/files/usr/libexec/termux-api Dialog "$@" /data/data/com.termux/files/usr/libexec/termux-api Dialog "$@"