summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/lib/libremessages36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/lib/libremessages b/src/lib/libremessages
index 93e6b86..78f9107 100755
--- a/src/lib/libremessages
+++ b/src/lib/libremessages
@@ -41,6 +41,7 @@
################################################################################
# Usage: panic
+#
# For programming errors, bails immediately with little fanfare.
panic() {
echo "$(_l _ 'panic: malformed call to internal function')" >&2
@@ -48,6 +49,7 @@ panic() {
}
# Usage: print MESG [ARGS...]
+#
# Like printf, but gettext-aware, and prints a trailing newline
print() {
[[ $# -ge 1 ]] || panic
@@ -56,8 +58,10 @@ print() {
printf -- "$mesg\n" "$@"
}
-# Do HTML-style whitespace collapsing on standard IO.
-# It considers newline, tab, and space to be whitespace.
+# Usage: _libremessages_html_whitespace_collapse <<<STRING
+#
+# Do HTML-style whitespace collapsing on standard IO. It considers
+# newline, tab, and space to be whitespace.
_libremessages_html_whitespace_collapse() {
[[ $# == 0 ]] || panic
tr '\n' ' ' | sed -r -e 's/\t/ /g' -e 's/ +/ /g'
@@ -65,9 +69,10 @@ _libremessages_html_whitespace_collapse() {
# Usage: prose MESG [ARGS...]
-# Do HTML-style whitespace collapsing on the first argument, translate it
-# (gettext), then word-wrap it to 75 columns.
-# This is useful for printing a paragraph of prose in --help text.
+#
+# Do HTML-style whitespace collapsing on the first argument, translate
+# it (gettext), then word-wrap it to 75 columns. This is useful for
+# printing a paragraph of prose in --help text.
prose() {
[[ $# -ge 1 ]] || panic
local mesg="$(_ "$(_libremessages_html_whitespace_collapse <<<"$1")")"; shift
@@ -85,14 +90,19 @@ bullet() {
}
# Usage: flag FLAG DESCRIPTION
+#
# Print a flag and description formatted for --help text.
+#
# ex: flag '-C <FILE>' 'Use this file instead of pacman.conf'
-# The description is fed through gettext, the flag is not, so if part of the
-# flag needs to be translated, you must do that yourself:
+#
+# The description is fed through gettext, the flag is not, so if part
+# of the flag needs to be translated, you must do that yourself:
+#
# ex: flag "-C <$(_ FILE)>" 'Use this file instead of pacman.conf'
+#
# If you want to line-break the description in the source, so it isn't
-# crazy-long, feel free, it is reflowed/wrapped the same way as prose and
-# bullet.
+# crazy-long, feel free, it is reflowed/wrapped the same way as prose
+# and bullet.
flag() {
[[ $# == 2 ]] || panic
local flag=$1
@@ -123,7 +133,8 @@ flag() {
}
# Usage: term_title MESG [ARGS...]
-# Sets the terminal title
+#
+# Sets the terminal title.
term_title() {
[[ $# -ge 1 ]] || panic
local fmt=''
@@ -135,8 +146,9 @@ term_title() {
}
# Usage: setup_traps [handler]
-# Sets up traps on TERM, HUP, QUIT and INT signals, as well as the ERR event,
-# similar to makepkg.
+#
+# Sets up traps on TERM, HUP, QUIT and INT signals, as well as the ERR
+# event, similar to makepkg.
#
# If `handler` is specified, instead of using the default handler
# (which is good for most purposes), it will call the command handler