Improve --help switch output for pacman contrib and pacman scripts

Unify the formatting of the --help switch for pacman utils, if it exists.
All of the pacman utils will now output help text using the following
format:

  util-name (pacman) v<pacman version>

  one line description of util's purpose

  Usage: util-name [options]

    -b, --bar      whatever --bar does
    -f, --foo      whatever --foo does
    -h, --help     display this help message

Reported-by: Karol Błażewicz <karol.blazewicz at gmail.com>
Signed-off-by: Jason St. John <jstjohn@purdue.edu>
This commit is contained in:
Jason St. John 2013-11-08 02:53:33 -05:00 committed by Allan McRae
parent 7bfaa358ea
commit a15fd48016
14 changed files with 99 additions and 54 deletions

View File

@ -37,9 +37,13 @@ m4_include(../scripts/library/output_format.sh)
# User Friendliness # User Friendliness
# #
usage() { usage() {
echo "This program recreates a package using pacman's db and system files" echo "${myname} (pacman) v${myver}"
echo "Usage: $myname [--nocolor] [--pacnew] <installed package name>" echo
echo "Example: $myname kernel26" echo "Recreate a package using pacman's database and system files"
echo
echo "Usage: ${myname} [--nocolor] [--pacnew] <installed package name>"
echo
echo "Example: ${myname} linux-headers"
} }
version() { version() {

View File

@ -18,10 +18,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
declare -r myname='checkupdates'
declare -r myver='@PACKAGE_VERSION@'
if (( $# > 0 )); then if (( $# > 0 )); then
echo "checkupdates: Safely print a list of pending updates." echo "${myname} (pacman) v${myver}"
echo "Use: checkupdates" echo
echo "Export the 'CHECKUPDATES_DB' variable to change the path of the temporary database." echo "Safely print a list of pending updates"
echo
echo "Usage: ${myname}"
echo
echo 'Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database.'
exit 0 exit 0
fi fi

View File

@ -152,27 +152,27 @@ summarize() {
usage() { usage() {
cat <<EOF cat <<EOF
usage: $myname <operation> [options] [targets...] ${myname} (pacman) v${myver}
$myname is a flexible pacman cache cleaning utility, which has numerous A flexible pacman cache cleaning utility.
options to help control how much, and what, is deleted from any directory
containing pacman package tarballs. Usage: ${myname} <operation> [options] [targets...]
Operations: Operations:
-d, --dryrun perform a dry run, only finding candidate packages. -d, --dryrun perform a dry run, only finding candidate packages.
-m, --move <dir> move candidate packages to 'movedir'. -m, --move <dir> move candidate packages to "movedir".
-r, --remove remove candidate packages. -r, --remove remove candidate packages.
Options: Options:
-a, --arch <arch> scan for 'arch' (default: all architectures). -a, --arch <arch> scan for "arch" (default: all architectures).
-c, --cachedir <dir> scan 'cachedir' for packages. -c, --cachedir <dir> scan "cachedir" for packages.
(default: @localstatedir@/cache/pacman/pkg). (default: @localstatedir@/cache/pacman/pkg).
-f, --force apply force to mv(1) and rm(1) operations. -f, --force apply force to mv(1) and rm(1) operations.
-h, --help display this help message and exit. -h, --help display this help message and exit.
-i, --ignore <pkgs> ignore 'pkgs', comma separated. Alternatively, specify -i, --ignore <pkgs> ignore "pkgs", comma-separated. Alternatively, specify
'-' to read package names from stdin, newline "-" to read package names from stdin, newline-
delimited. delimited.
-k, --keep <num> keep 'num' of each package in 'cachedir' (default: 3). -k, --keep <num> keep "num" of each package in "cachedir" (default: 3).
--nocolor remove color from output. --nocolor remove color from output.
-u, --uninstalled target uninstalled packages. -u, --uninstalled target uninstalled packages.
-v, --verbose increase verbosity. specify up to 3 times. -v, --verbose increase verbosity. specify up to 3 times.

View File

@ -33,20 +33,22 @@ m4_include(../scripts/library/output_format.sh)
usage() { usage() {
cat <<EOF cat <<EOF
$myname is a simple pacnew/pacorig/pacsave updater. ${myname} (pacman) v${myver}
A simple program to merge or remove pacnew/pacorig/pacsave files.
Usage: $myname [-l | -f | -p] [--nocolor] Usage: $myname [-l | -f | -p] [--nocolor]
Search Options: select one, default: pacmandb Search Options: select one, default: pacmandb
-l/--locate scan using locate -l/--locate scan using locate
-f/--find scan using find -f/--find scan using find
-p/--pacmandb scan active config files from pacman db -p/--pacmandb scan active config files from pacman database
General Options: General Options:
-o/--output print files instead of merging them -o/--output print files instead of merging them
--nocolor remove colors from output --nocolor remove colors from output
Enviroment Variables: Environment Variables:
DIFFPROG override the merge program: (default: vimdiff) DIFFPROG override the merge program: (default: vimdiff)
DIFFSEARCHPATH override the search path. (only when using find) DIFFSEARCHPATH override the search path. (only when using find)
(default: /etc) (default: /etc)

View File

@ -31,9 +31,13 @@ if ! type gettext &>/dev/null; then
fi fi
usage() { usage() {
printf '%s - List all packages installed from a given repo\n' "$myname" printf "%s (pacman) v%s\n" "${myname}" "myver"
printf 'Usage: %s <repo>\n' "$myname" echo
printf 'Example: %s testing\n' "$myname" printf "List all packages installed from a given repository\n" "${myname}"
echo
printf "Usage: %s <repository>\n" "${myname}"
echo
printf "Example: %s testing\n" "${myname}"
} }
version() { version() {

View File

@ -25,9 +25,15 @@ export TEXTDOMAINDIR='/usr/share/locale'
declare logfile=${1:-@localstatedir@/log/pacman.log} declare logfile=${1:-@localstatedir@/log/pacman.log}
usage() { usage() {
printf 'usage: %s [pacman log]\n' "$myname" printf "%s (pacman) v%s\n" "${myname}" "${myver}"
printf 'example: %s @localstatedir@/log/pacman.log\n' "$myname" echo
printf '\ndefaults to: @localstatedir@/log/pacman.log\n' echo "Parse a log file into a list of currently installed packages"
echo
printf "Usage: %s [path to pacman log]\n" "${myname}"
echo
printf "Example: %s @localstatedir@/log/pacman.log\n" "${myname}"
echo
printf 'Defaults to: @localstatedir@/log/pacman.log'
} }
version() { version() {

View File

@ -46,16 +46,18 @@ error() {
} }
usage() { usage() {
echo "This program prints out the {pre,post}_{install,remove,upgrade} scripts" echo "${myname} (pacman) v${myver}"
echo "of a given package."
echo "Usage: $myname pkgname|pkgfile"
echo echo
echo " OPTIONS:" echo "Prints the {pre,post}_{install,remove,upgrade} scripts of a given package."
echo
echo "Usage: ${myname} <pkgname|pkgfile>"
echo
echo " Options:"
echo " -h, --help Print this help message" echo " -h, --help Print this help message"
echo " -v, --version Print program name and version" echo " -v, --version Print program name and version"
echo echo
echo "Example: $myname gconf-editor" echo "Example: ${myname} gconf-editor"
echo "Example: $myname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz" echo "Example: ${myname} gconf-editor-3.0.1-3-x86_64.pkg.tar.xz"
} }
version() { version() {
@ -70,7 +72,7 @@ spacman() {
else else
if ! type -p sudo; then if ! type -p sudo; then
error "Cannot find the sudo binary! Is sudo installed?" error "Cannot find the sudo binary! Is sudo installed?"
error "Otherwise try to run the program as root" error "Otherwise, try to run the program as root"
exit 1 exit 1
else else
sudo pacman "$@" sudo pacman "$@"

View File

@ -28,8 +28,9 @@ my $myname = 'pacsearch';
my $myver = '@PACKAGE_VERSION@'; my $myver = '@PACKAGE_VERSION@';
sub usage { sub usage {
print "$myname - Add color and install information to a pacman -Ss search\n"; print "$myname (pacman) v$myver\n\n";
print "Usage: $myname <pattern>\n"; print "Add color and install information to a 'pacman -Ss' search\n\n";
print "Usage: $myname <pattern>\n\n";
print "Example: $myname ^gnome\n"; print "Example: $myname ^gnome\n";
} }

View File

@ -8,9 +8,12 @@ declare -r myver='@PACKAGE_VERSION@'
PACMAN_OPTS= PACMAN_OPTS=
usage() { usage() {
echo "$myname - Sort installed packages by increasing installed size." echo "${myname} (pacman) v${myver}"
echo echo
echo "Usage: $myname [options]" echo "Sort installed packages by increasing installed size. Useful for"
echo "system clean-up."
echo
echo "Usage: ${myname} [options]"
echo echo
echo "Options:" echo "Options:"
echo " -o <options> Specify custom pacman query options (e.g., dt)" echo " -o <options> Specify custom pacman query options (e.g., dt)"
@ -22,7 +25,6 @@ version() {
echo 'Copyright (C) 2011 Eric Bélanger <snowmaniscool@gmail.com>' echo 'Copyright (C) 2011 Eric Bélanger <snowmaniscool@gmail.com>'
} }
if [ -n "$1" ]; then if [ -n "$1" ]; then
case "$1" in case "$1" in
-o) PACMAN_OPTS="${2}" ;; -o) PACMAN_OPTS="${2}" ;;

View File

@ -21,26 +21,31 @@
# traps interrupt key to spit out pre-interrupt info # traps interrupt key to spit out pre-interrupt info
trap finaloutput INT trap finaloutput INT
declare -r myname='rankmirrors'
declare -r myver='@PACKAGE_VERSION@'
usage() { usage() {
echo "Usage: rankmirrors [options] MIRRORFILE | URL" echo "${myname} (pacman) v${myver}"
echo echo
echo "Ranks pacman mirrors by their connection and opening speed. Pacman mirror" echo "Ranks pacman mirrors by their connection and opening speed. Pacman mirror"
echo "files are located in @sysconfdir@/pacman.d/. It can also rank one mirror if the URL is" echo "files are located in @sysconfdir@/pacman.d/. It can also rank one mirror if the URL is"
echo "provided." echo "provided."
echo echo
echo "Usage: ${myname} [options] MIRRORFILE | URL"
echo
echo "Options:" echo "Options:"
echo " --version show program's version number and exit" echo " --version show program's version number and exit"
echo " -h, --help show this help message and exit" echo " -h, --help show this help message and exit"
echo " -n NUM number of servers to output, 0 for all" echo " -n NUM number of servers to output, 0 for all"
echo " -t, --times only output mirrors and their response times" echo " -t, --times only output mirrors and their response times"
echo " -u, --url test a specific url" echo " -u, --url test a specific URL"
echo " -v, --verbose be verbose in ouptut" echo " -v, --verbose be verbose in ouptut"
echo " -r, --repo specify a specific repo name instead of guessing" echo " -r, --repo specify a repository name instead of guessing"
exit 0 exit 0
} }
version() { version() {
echo "rankmirrors (pacman) @PACKAGE_VERSION@" echo "${myname} (pacman) ${myver}"
echo "Copyright (c) 2009 Matthew Bruenig <matthewbruenig@gmail.com>." echo "Copyright (c) 2009 Matthew Bruenig <matthewbruenig@gmail.com>."
echo echo
echo "This is free software; see the source for copying conditions." echo "This is free software; see the source for copying conditions."

View File

@ -23,12 +23,16 @@ declare -r myname='updpkgsums'
declare -r myver='@PACKAGE_VERSION@' declare -r myver='@PACKAGE_VERSION@'
usage() { usage() {
printf 'usage: %s [buildfile]\n\n' "$myname" printf "%s (pacman) v%s\n" "${myname}" "${myver}"
printf ' -h, --help display this help message and exit\n' echo
printf ' -V, --version display version information and exit\n\n' printf "%s will perform an in place update of the checksums in the\n" "${myname}"
printf '%s will perform an in place update the checksums in the\n' "$myname" echo "path specified by [build file], defaulting to PKGBUILD in the current"
printf 'path specified by [buildfile], defaulting to PKGBUILD in the current\n' echo "working directory."
printf 'working directory.\n' echo
printf "Usage: %s [build file]\n" "${myname}"
echo
echo " -h, --help display this help message and exit"
echo " -V, --version display version information and exit"
} }
version() { version() {
@ -43,7 +47,7 @@ esac
buildfile=${1:-PKGBUILD} buildfile=${1:-PKGBUILD}
if [[ ! -f $buildfile ]]; then if [[ ! -f $buildfile ]]; then
printf '==> ERROR: %s not found or is not a file\n' "$buildfile" printf "==> ERROR: %s not found or is not a file\n" "$buildfile"
exit 1 exit 1
fi fi

View File

@ -2483,6 +2483,8 @@ m4_include(library/parseopts.sh)
usage() { usage() {
printf "makepkg (pacman) %s\n" "$makepkg_version" printf "makepkg (pacman) %s\n" "$makepkg_version"
echo echo
printf -- "$(gettext "Make packages compatible for use with pacman")\n"
echo
printf -- "$(gettext "Usage: %s [options]")\n" "$0" printf -- "$(gettext "Usage: %s [options]")\n" "$0"
echo echo
printf -- "$(gettext "Options:")\n" printf -- "$(gettext "Options:")\n"

View File

@ -33,8 +33,11 @@ USE_COLOR='y'
m4_include(library/output_format.sh) m4_include(library/output_format.sh)
usage() { usage() {
printf "pacman-db-upgrade (pacman) %s\n\n" "$myver" printf "pacman-db-upgrade (pacman) %s\n" "${myver}"
printf -- "$(gettext "Usage: %s [--nocolor] [pacman_db_root]")\n\n" "$0" echo
printf -- "$(gettext "Upgrade the local pacman database to a newer format")\n"
echo
printf -- "$(gettext "Usage: %s [--nocolor] [pacman_db_root]")\n" "$0"
} }
version() { version() {

View File

@ -46,11 +46,14 @@ m4_include(library/output_format.sh)
# print usage instructions # print usage instructions
usage() { usage() {
printf "pkgdelta (pacman) %s\n\n" "$myver" printf "pkgdelta (pacman) %s\n" "${myver}"
echo
printf -- "$(gettext "Usage: pkgdelta [options] <package1> <package2>\n")" printf -- "$(gettext "Usage: pkgdelta [options] <package1> <package2>\n")"
echo
printf -- "$(gettext "\ printf -- "$(gettext "\
pkgdelta will create a delta file between two packages.\n\ pkgdelta will create a delta file between two packages.\n\
This delta file can then be added to a database using repo-add.\n\n")" This delta file can then be added to a database using repo-add.\n")"
echo
printf -- "$(gettext "Example: pkgdelta pacman-3.0.0.pkg.tar.gz pacman-3.0.1.pkg.tar.gz")\n" printf -- "$(gettext "Example: pkgdelta pacman-3.0.0.pkg.tar.gz pacman-3.0.1.pkg.tar.gz")\n"
echo echo
printf -- "$(gettext "Options:\n")" printf -- "$(gettext "Options:\n")"
@ -61,7 +64,7 @@ This delta file can then be added to a database using repo-add.\n\n")"
} }
version() { version() {
printf "pkgdelta (pacman) %s\n\n" "$myver" printf "pkgdelta (pacman) %s\n" "$myver"
printf -- "$(gettext "\ printf -- "$(gettext "\
Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>.\n\n\ Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>.\n\n\
This is free software; see the source for copying conditions.\n\ This is free software; see the source for copying conditions.\n\