Commit 91872a73 authored by Emeric Verschuur's avatar Emeric Verschuur

Update prompt display

parent de4f6c57
......@@ -442,6 +442,27 @@ bashopts_parse_args() {
bashopts_commands=("$@")
}
bashopts_dump_array() {
local type=$1
shift || bashopts_error "Usage: bashopts_dump_array type elt1 [elt2...]"
echo -n "["
if [ "$type" == "string" ]; then
echo -n "\"${1//\"/\\\"}\""
else
echo -n "${1}"
fi
shift || true
while [ -n "$1" ]; do
if [ "$type" == "string" ]; then
echo -n ", \"${1//\"/\\\"}\""
else
echo -n ", ${1}"
fi
shift
done
echo -n "]"
}
# STEP 4: process arg
bashopts_process_args() {
local dval ival
......@@ -449,6 +470,7 @@ bashopts_process_args() {
bashopts_non_interactive="true"
fi
for op in "${bashopts_optlist[@]}"; do
unset dval
# eval or get default value
if [[ -v bashopts_optprop_expression[$op] ]]; then
eval "dval=${bashopts_optprop_expression[$op]}"
......@@ -472,7 +494,7 @@ bashopts_process_args() {
if [ "${bashopts_optprop_interactive[$op]}" == "true" ] && [ "$bashopts_non_interactive" != "true" ]; then
while true; do
echo "* ${bashopts_optprop_description[$op]}"
echo -n " [$(bashopts_get_def tval)]: "
echo -n " $(bashopts_dump_array {bashopts_optprop_type[$op]} "${tval[@]}"): "
read ival
if [ -z "$ival" ]; then
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment