pacman-key help, round three

Make it actually like all our other tools rather than some homegrown
format. Also make it translator friendly by not wrapping messages across
lines in different strings.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-03-23 01:24:28 -05:00
parent 482da2eceb
commit 964e8c5bf2

View file

@ -50,41 +50,34 @@ error() {
usage() { usage() {
printf "pacman-key (pacman) %s\n" ${myver} printf "pacman-key (pacman) %s\n" ${myver}
echo echo
printf "$(gettext "Usage: %s [options] command [arguments]")\n" $(basename $0) printf "$(gettext "Usage: %s [options] <command> [arguments]")\n" $(basename $0)
echo echo
echo "$(gettext "Manage pacman's list of trusted keys")" echo "$(gettext "Manage pacman's list of trusted keys")"
echo echo
echo "$(gettext "Options must be placed before commands. The available options are:")" echo "$(gettext "Options must be placed before commands. The available options are:")"
echo "$(gettext " --config - set an alternative configuration file to use. ")" printf "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$CONFIG"
printf "$(gettext " Default is %s")\n" "@sysconfdir@/pacman.conf" echo "$(gettext " --gpgdir Set an alternate directory for gnupg")"
echo "$(gettext " --gpgdir - set an alternative home directory for gnupg. ")"
printf "$(gettext " Default is set in %s")\n" "@sysconfdir@/pacman.conf"
echo echo
echo "$(gettext "The available commands are:")" echo "$(gettext "The available commands are:")"
echo "$(gettext " -a | --add [<file>] ... - add the key contained in <file>")" echo "$(gettext " -a, --add [<file(s)>] Add the specified keys (empty for stdin)")"
echo "$(gettext " (empty for stdin)")" echo "$(gettext " -d, --del <keyid(s)> Remove the specified keyids")"
echo "$(gettext " -d | --del <keyid> ... - remove the key <keyid>")" echo "$(gettext " -e, --export <keyid(s)> Export the specified keyids")"
echo "$(gettext " -e | --export <keyid> ... - output the key <keyid>")" echo "$(gettext " -f, --finger [<keyid(s)>] List fingerprint for specified or all keyids")"
echo "$(gettext " -f | --finger [<keyid>] ... - list fingerprint for specified keyids")" echo "$(gettext " -h, --help This help")"
echo "$(gettext " (or for all, if no key is specified)")" echo "$(gettext " -l, --list List keys")"
echo "$(gettext " -h | --help - displays this message")" echo "$(gettext " -r, --receive <keyserver> <keyid(s)> Fetch the specified keyids")"
echo "$(gettext " -l | --list - list keys")" echo "$(gettext " -t, --trust <keyid(s)> Set the trust level of the given keyids")"
echo "$(gettext " -r | --receive <keyserver> <keyid> ... - fetch the keyids from the specified")" echo "$(gettext " -u, --updatedb Update the trustdb of pacman")"
echo "$(gettext " keyserver URL")" echo "$(gettext " -V, --version Show program version")"
echo "$(gettext " -t | --trust <keyid> ... - set the trust level of the given key")" echo "$(gettext " --adv <params> Use pacman's keyring with advanced gpg commands")"
echo "$(gettext " -u | --updatedb - update the trustdb of pacman")" printf "$(gettext " --reload Reload the default keys")"
echo "$(gettext " -v | --version - displays the current version")"
echo "$(gettext " --adv <params> - use pacman's keyring as target for")"
echo "$(gettext " advanced gpg commands")"
echo "$(gettext " --reload - reloads the keys supplied by your")"
printf "$(gettext " distribution in %s")"'@prefix@/share/pacman'
echo echo
} }
version() { version() {
printf "pacman-key (pacman) %s\n" "${myver}" printf "pacman-key (pacman) %s\n" "${myver}"
printf "$(gettext "\ printf "$(gettext "\
Copyright (c) 2010 Pacman Development Team <pacman-dev@archlinux.org>.\n\ Copyright (c) 2010-2011 Pacman Development Team <pacman-dev@archlinux.org>.\n\
This is free software; see the source for copying conditions.\n\ This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")" There is NO WARRANTY, to the extent permitted by law.\n")"
} }
@ -218,7 +211,7 @@ if ! type gettext &>/dev/null; then
} }
fi fi
if [[ $1 != "--version" && $1 != "-v" && $1 != "--help" && $1 != "-h" && $1 != "" ]]; then if [[ $1 != "--version" && $1 != "-V" && $1 != "--help" && $1 != "-h" && $1 != "" ]]; then
if type -p gpg >/dev/null 2>&1 = 1; then if type -p gpg >/dev/null 2>&1 = 1; then
error "$(gettext "gnupg does not seem to be installed.")" error "$(gettext "gnupg does not seem to be installed.")"
msg2 "$(gettext "pacman-key requires gnupg for most operations.")" msg2 "$(gettext "pacman-key requires gnupg for most operations.")"
@ -241,7 +234,7 @@ while [[ $1 =~ ^--(config|gpgdir)$ ]]; do
done done
if [[ ! -r "${CONFIG}" ]]; then if [[ ! -r "${CONFIG}" ]]; then
error "$(gettext "It is not possible to read %s")" "${CONFIG}" error "$(gettext "%s not found.")" "$CONFIG"
exit 1 exit 1
fi fi
@ -269,7 +262,6 @@ case "${command}" in
-d|--del) -d|--del)
if (( $# == 0 )); then if (( $# == 0 )); then
error "$(gettext "You need to specify at least one key identifier")" error "$(gettext "You need to specify at least one key identifier")"
usage
exit 1 exit 1
fi fi
${GPG_PACMAN} --quiet --batch --delete-key --yes "$@" ${GPG_PACMAN} --quiet --batch --delete-key --yes "$@"
@ -284,7 +276,7 @@ case "${command}" in
${GPG_PACMAN} --batch --list-sigs "$@" ${GPG_PACMAN} --batch --list-sigs "$@"
;; ;;
-f|--finger) -f|--finger)
${GPG_PACMAN} --batch --fingerprint $* ${GPG_PACMAN} --batch --fingerprint "$@"
;; ;;
-e|--export) -e|--export)
${GPG_PACMAN} --armor --export "$@" ${GPG_PACMAN} --armor --export "$@"
@ -292,7 +284,6 @@ case "${command}" in
-r|--receive) -r|--receive)
if (( $# < 2 )); then if (( $# < 2 )); then
error "$(gettext "You need to specify the keyserver and at least one key identifier")" error "$(gettext "You need to specify the keyserver and at least one key identifier")"
usage
exit 1 exit 1
fi fi
keyserver="$1" keyserver="$1"
@ -302,7 +293,6 @@ case "${command}" in
-t|--trust) -t|--trust)
if (( $# == 0 )); then if (( $# == 0 )); then
error "$(gettext "You need to specify at least one key identifier")" error "$(gettext "You need to specify at least one key identifier")"
usage
exit 1 exit 1
fi fi
while (( $# > 0 )); do while (( $# > 0 )); do
@ -322,14 +312,9 @@ case "${command}" in
exit $ret exit $ret
;; ;;
-h|--help) -h|--help)
usage usage; exit 0 ;;
;; -V|--version)
-v | --version) version; exit 0 ;;
version
exit 0
;;
*) *)
usage usage; exit 1 ;;
exit 1
;;
esac esac