[pacman-dev] [RFC v2 10/13] pacscripts: streamline usage function
Gordian Edenhofer
gordian.edenhofer at gmail.com
Thu Sep 29 12:41:23 UTC 2016
Signed-off-by: Gordian Edenhofer <gordian.edenhofer at gmail.com>
---
contrib/pacscripts.sh.in | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/contrib/pacscripts.sh.in b/contrib/pacscripts.sh.in
index 4a1e0c5..40fd4be 100644
--- a/contrib/pacscripts.sh.in
+++ b/contrib/pacscripts.sh.in
@@ -27,6 +27,17 @@ set -o errexit
declare -r myname='pacscripts'
declare -r myver='@PACKAGE_VERSION@'
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+ gettext() {
+ printf "%s\n" "$@"
+ }
+fi
+
conf="@sysconfdir@/pacman.conf"
if [ ! -r "$conf" ]; then
@@ -45,18 +56,20 @@ error() {
}
usage() {
- echo "${myname} (pacman) v${myver}"
+ printf "%s (pacman) %s\n" "$myname" "$myver"
+ echo
+ printf -- "$(gettext "Prints the {pre,post}_{install,remove,upgrade} scripts of a given package")\n"
echo
- echo "Prints the {pre,post}_{install,remove,upgrade} scripts of a given package."
+ printf -- "$(gettext "Usage: %s <pkgname|pkgfile>")\n" "$0"
echo
- echo "Usage: ${myname} <pkgname|pkgfile>"
+ printf -- "$(gettext "Options:")\n"
+ printf -- "$(gettext " -h, --help Print this help message")\n"
+ printf -- "$(gettext " -v, --version Print program name and version")\n"
echo
- echo " Options:"
- echo " -h, --help Print this help message"
- echo " -v, --version Print program name and version"
+ printf -- "$(gettext "Examples:")"
+ printf -- " %s gconf-editor\n" "$myname"
+ printf -- " %s gconf-editor-3.0.1-3-x86_64.pkg.tar.xz\n" "$myname"
echo
- echo "Example: ${myname} gconf-editor"
- echo "Example: ${myname} gconf-editor-3.0.1-3-x86_64.pkg.tar.xz"
}
version() {
--
2.10.0
More information about the pacman-dev
mailing list