summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/lib/libremessages37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/lib/libremessages b/src/lib/libremessages
index 151674b..528d9b6 100755
--- a/src/lib/libremessages
+++ b/src/lib/libremessages
@@ -110,16 +110,20 @@ bullet() {
# the descriptions are all alligned together.
flag() {
[[ $# == $(($#/2*2)) ]] || panic
-
local args=("$@")
+
declare -i flaglen=0
- declare -i i=0
- while [[ $i -lt $# ]]; do
- if [[ ${#args[i]} -gt $flaglen ]]; then
- flaglen=${#args[$i]}
+ while [[ $# -gt 0 ]]; do
+ if [[ $1 == *: ]]; then
+ shift 1
+ else
+ if [[ ${#1} -gt $flaglen ]]; then
+ flaglen=${#1}
+ fi
+ shift 2
fi
- i+=2
done
+ set -- "${args[@]}"
# Unless the $flaglen is extra-wide, the $desc should start at
# column 16 (that is two literal-tabs). If $flaglen is wide,
@@ -140,14 +144,19 @@ flag() {
printf -v fmt1 " %-${indent}s %%s\n" ''
while [[ $# -gt 0 ]]; do
- local flag=$1
- local desc="$(_ "$(whitespace_collapse <<<"$2")")"
- shift 2
-
- local lines
- IFS=$'\n' lines=($(fmt -u -w $((71-indent)) <<<"$desc"))
- printf -- "$fmt2" "$flag" "${lines[0]}"
- [[ ${#lines[@]} -lt 2 ]] || printf -- "$fmt1" "${lines[@]:1}"
+ if [[ $1 == *: ]]; then
+ printf -- ' %s\n' "$(_ "$1")"
+ shift
+ else
+ local flag=$1
+ local desc="$(_ "$(whitespace_collapse <<<"$2")")"
+ shift 2
+
+ local lines
+ IFS=$'\n' lines=($(fmt -u -w $((71-indent)) <<<"$desc"))
+ printf -- "$fmt2" "$flag" "${lines[0]}"
+ [[ ${#lines[@]} -lt 2 ]] || printf -- "$fmt1" "${lines[@]:1}"
+ fi
done
}