diff options
-rwxr-xr-x | src/lib/libremessages | 18 | ||||
-rw-r--r-- | src/lib/libremessages.1.ronn | 14 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/lib/libremessages b/src/lib/libremessages index db2fdde..f75bd4a 100755 --- a/src/lib/libremessages +++ b/src/lib/libremessages @@ -47,7 +47,7 @@ panic() { exit 1 } -# Usage: print MESG ARG1 ARG2... +# Usage: print MESG [ARGS...] # Like printf, but gettext-aware, and prints a trailing newline print() { [[ $# -ge 1 ]] || panic @@ -58,28 +58,28 @@ print() { # Do HTML-style whitespace collapsing on standard IO. # It considers newline, tab, and space to be whitespace. -_html_whitespace_collapse() { +_libremessages_html_whitespace_collapse() { [[ $# == 0 ]] || panic tr '\n' ' ' | sed -r -e 's/\t/ /g' -e 's/ +/ /g' } -# Usage: prose MESG +# 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. prose() { [[ $# -ge 1 ]] || panic - local mesg="$(_ "$(_html_whitespace_collapse <<<"$1")")"; shift + local mesg="$(_ "$(_libremessages_html_whitespace_collapse <<<"$1")")"; shift printf -- "$mesg" "$@" | fmt -u } -# Usage: bullet MESG +# Usage: bullet MESG [ARGS...] # Like prose, but print a bullet "-" before the first line, and indent the # remaining lines. bullet() { [[ $# -ge 1 ]] || panic - local mesg="$(_ "$(_html_whitespace_collapse <<<"$1")")"; shift + local mesg="$(_ "$(_libremessages_html_whitespace_collapse <<<"$1")")"; shift # Wrap the text to 71 columns; 75 (the default) minus a 4 column indent printf -- "$mesg" "$@" | fmt -u -w 71 | sed -e '1s/^/ - /' -e '2,$s/^/ /' } @@ -96,7 +96,7 @@ bullet() { flag() { [[ $# == 2 ]] || panic local flag=$1 - local desc="$(_ "$(_html_whitespace_collapse <<<"$2")")" + local desc="$(_ "$(_libremessages_html_whitespace_collapse <<<"$2")")" declare -i indent=13 while [[ $indent -le ${#flag} ]]; do @@ -162,7 +162,5 @@ setup_traps() { if [[ "${0##*/}" == libremessages ]]; then set -euE - _libremessages_cmd=$1 - shift - "$_libremessages_cmd" "$@" + "$@" fi diff --git a/src/lib/libremessages.1.ronn b/src/lib/libremessages.1.ronn index 6f1ecf5..daafd2f 100644 --- a/src/lib/libremessages.1.ronn +++ b/src/lib/libremessages.1.ronn @@ -71,8 +71,8 @@ Unless otherwise noted, these do not implicitly call `gettext`. using the default handler (which is good for most purposes), it will call <HANDLER> with the arguments `<HANDLER> <SIGNAL_NAME> <MESSAGE> [<MESSAGE_ARGS>...]`, where - <MESSAGE> is a `printf`(1)-formatted string, and <MESSAGE_ARGS> - are its arguments. + <MESSAGE> is a `printf`(1)-formatted string that is fed through + `gettext`, and <MESSAGE_ARGS> are its arguments. ### PROSE ROUTINES @@ -81,10 +81,6 @@ word-wrapped prose. For each of these, <MESSAGE> is fed through `gettext` automatically. - * `print` <MESSAGE> [<ARGS>...]: - Like `printf`(1), but `gettext`-aware, and automatically prints a - trailing newline. - * `prose` <MESSAGE> [<ARGS>...]: Takes a `printf`(1)-formatted string, collapses whitespace (HTML-style), and then word-wraps it. @@ -114,7 +110,7 @@ any arguments. Each of these print to stderr, not stdout. For each of these, <MESSAGE> is fed through `gettext` automatically. * `plain` <MESSAGE> [<ARGS>...]: - Prints "plain" message in bold, indented with 4 spaces. + Prints a "plain" message in bold, indented with 4 spaces. * `msg` <MESSAGE> [<ARGS>...]: Prints a top-level priority notification. @@ -134,6 +130,10 @@ For each of these, <MESSAGE> is fed through `gettext` automatically. * `stat_done`: Prints a "done" type message to terminate `stat_busy`. + * `print` <MESSAGE> [<ARGS>...]: + Like `printf`(1), but `gettext`-aware, and automatically prints a + trailing newline. + * `term_title` <MESSAGE> [<ARGS>...]: Sets the terminal title to the specified message. |