1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 08:18:51 -05:00

Improve --help switch output for pacman utils

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

The --help switch does not exist for a couple of the utils, so the
help/usage text for those will be displayed when the util is run
with no arguments.

Reported-by: Karol Błażewicz <karol.blazewicz at gmail.com>
Signed-off-by: Jason St. John <jstjohn@purdue.edu>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Jason St. John 2013-09-03 15:20:50 -04:00 committed by Allan McRae
parent 4245c6b222
commit a86015f73f
6 changed files with 28 additions and 28 deletions

View File

@ -24,8 +24,6 @@
#include <alpm.h> #include <alpm.h>
#include <alpm_list.h> #include <alpm_list.h>
#define BASENAME "cleanupdelta"
alpm_handle_t *handle = NULL; alpm_handle_t *handle = NULL;
static void cleanup(int signum) static void cleanup(int signum)
@ -87,9 +85,10 @@ static void checkdbs(alpm_list_t *dbnames)
static void usage(void) static void usage(void)
{ {
fprintf(stderr, "usage:\n"); fprintf(stderr, "cleanupdelta (pacman) v" PACKAGE_VERSION "\n\n"
fprintf(stderr, "Returns a list of unused delta in a given sync database.\n\n"
"\t%s [-b <pacman db>] core extra ... : check the listed sync databases\n", BASENAME); "Usage: cleanupdelta [options]\n\n"
" -b <pacman db> core extra ... : check the listed sync databases\n");
exit(1); exit(1);
} }

View File

@ -343,7 +343,8 @@ static char escape_char(const char *string)
static void usage(void) static void usage(void)
{ {
fprintf(stderr, "pacsort v" PACKAGE_VERSION "\n" fprintf(stderr, "pacsort (pacman) v" PACKAGE_VERSION "\n\n"
"A sort utility implementing alpm_pkg_vercmp.\n\n"
"Usage: pacsort [options] [files...]\n\n" "Usage: pacsort [options] [files...]\n\n"
" -f, --files assume inputs are file paths of packages\n" " -f, --files assume inputs are file paths of packages\n"
" -h, --help display this help message\n" " -h, --help display this help message\n"

View File

@ -310,9 +310,10 @@ static int parse_options(int argc, char *argv[])
static void usage(void) static void usage(void)
{ {
fprintf(stderr, "pactree v" PACKAGE_VERSION "\n" fprintf(stderr, "pactree (pacman) v" PACKAGE_VERSION "\n\n"
"A simple dependency tree viewer.\n\n"
"Usage: pactree [options] PACKAGE\n\n" "Usage: pactree [options] PACKAGE\n\n"
" -a, --ascii use ascii characters for tree formatting\n" " -a, --ascii use ASCII characters for tree formatting\n"
" -b, --dbpath <path> set an alternate database location\n" " -b, --dbpath <path> set an alternate database location\n"
" -c, --color colorize output\n" " -c, --color colorize output\n"
" -d, --depth <#> limit the depth of recursion\n" " -d, --depth <#> limit the depth of recursion\n"
@ -320,7 +321,7 @@ static void usage(void)
" -h, --help display this help message\n" " -h, --help display this help message\n"
" -l, --linear enable linear output\n" " -l, --linear enable linear output\n"
" -r, --reverse list packages that depend on the named package\n" " -r, --reverse list packages that depend on the named package\n"
" -s, --sync search sync DBs instead of local\n" " -s, --sync search sync databases instead of local\n"
" -u, --unique show dependencies with no duplicates (implies -l)\n" " -u, --unique show dependencies with no duplicates (implies -l)\n"
" --config <path> set an alternate configuration file\n"); " --config <path> set an alternate configuration file\n");
} }

View File

@ -27,8 +27,6 @@
#include <alpm.h> #include <alpm.h>
#include <alpm_list.h> #include <alpm_list.h>
#define BASENAME "testdb"
alpm_handle_t *handle = NULL; alpm_handle_t *handle = NULL;
static void cleanup(int signum) static void cleanup(int signum)
@ -244,11 +242,11 @@ cleanup:
static void usage(void) static void usage(void)
{ {
fprintf(stderr, "usage:\n"); fprintf(stderr, "testdb (pacman) v" PACKAGE_VERSION "\n\n"
fprintf(stderr, "Test a pacman local database for validity.\n\n"
"\t%s [-b <pacman db>] : check the local database\n", BASENAME); "Usage: testdb [options]\n\n"
fprintf(stderr, " -b <pacman db> : check the local database\n"
"\t%s [-b <pacman db>] core extra ... : check the listed sync databases\n", BASENAME); " -b <pacman db> core extra ... : check the listed sync databases\n");
exit(1); exit(1);
} }

View File

@ -22,8 +22,6 @@
#include <alpm.h> #include <alpm.h>
#define BASENAME "testpkg"
__attribute__((format(printf, 2, 0))) __attribute__((format(printf, 2, 0)))
static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args) static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args)
{ {
@ -47,7 +45,9 @@ int main(int argc, char *argv[])
const alpm_siglevel_t level = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL; const alpm_siglevel_t level = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL;
if(argc != 2) { if(argc != 2) {
fprintf(stderr, "usage: %s <package file>\n", BASENAME); fprintf(stderr, "testpkg (pacman) v" PACKAGE_VERSION "\n\n"
"Test a pacman package for validity.\n\n"
"Usage: testpkg <package file>\n");
return 1; return 1;
} }

View File

@ -1,5 +1,6 @@
/* /*
* vercmp.c * vercmp.c - Compare package version numbers using pacman's version
* comparison logic
* *
* Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2005 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2005 by Judd Vinet <jvinet@zeroflux.org>
@ -22,19 +23,19 @@
#include <stdio.h> /* printf */ #include <stdio.h> /* printf */
#include <string.h> #include <string.h>
#define BASENAME "vercmp"
/* forward declaration, comes from version.o in libalpm source that is linked /* forward declaration, comes from version.o in libalpm source that is linked
* in directly so we don't have any library deps */ * in directly so we don't have any library deps */
int alpm_pkg_vercmp(const char *a, const char *b); int alpm_pkg_vercmp(const char *a, const char *b);
static void usage(void) static void usage(void)
{ {
fprintf(stderr, "usage: %s <ver1> <ver2>\n\n", BASENAME); fprintf(stderr, "vercmp (pacman) v" PACKAGE_VERSION "\n\n"
fprintf(stderr, "output values:\n"); "Compare package version numbers using pacman's version comparison logic.\n\n"
fprintf(stderr, " < 0 : if ver1 < ver2\n"); "Usage: vercmp <ver1> <ver2>\n\n"
fprintf(stderr, " 0 : if ver1 == ver2\n"); "Output values:\n"
fprintf(stderr, " > 0 : if ver1 > ver2\n"); " < 0 : if ver1 < ver2\n"
" 0 : if ver1 == ver2\n"
" > 0 : if ver1 > ver2\n");
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])