From a86015f73fdda878287a2ad21011594862bf506a Mon Sep 17 00:00:00 2001 From: "Jason St. John" Date: Tue, 3 Sep 2013 15:20:50 -0400 Subject: Improve --help switch output for pacman utils MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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 Signed-off-by: Jason St. John Signed-off-by: Allan McRae --- src/util/cleanupdelta.c | 9 ++++----- src/util/pacsort.c | 5 +++-- src/util/pactree.c | 7 ++++--- src/util/testdb.c | 12 +++++------- src/util/testpkg.c | 6 +++--- src/util/vercmp.c | 17 +++++++++-------- 6 files changed, 28 insertions(+), 28 deletions(-) (limited to 'src/util') diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c index 4f344350..b13d770b 100644 --- a/src/util/cleanupdelta.c +++ b/src/util/cleanupdelta.c @@ -24,8 +24,6 @@ #include #include -#define BASENAME "cleanupdelta" - alpm_handle_t *handle = NULL; static void cleanup(int signum) @@ -87,9 +85,10 @@ static void checkdbs(alpm_list_t *dbnames) static void usage(void) { - fprintf(stderr, "usage:\n"); - fprintf(stderr, - "\t%s [-b ] core extra ... : check the listed sync databases\n", BASENAME); + fprintf(stderr, "cleanupdelta (pacman) v" PACKAGE_VERSION "\n\n" + "Returns a list of unused delta in a given sync database.\n\n" + "Usage: cleanupdelta [options]\n\n" + " -b core extra ... : check the listed sync databases\n"); exit(1); } diff --git a/src/util/pacsort.c b/src/util/pacsort.c index 7c551c2b..687e558d 100644 --- a/src/util/pacsort.c +++ b/src/util/pacsort.c @@ -343,9 +343,10 @@ static char escape_char(const char *string) 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" - " -f, --files assume inputs are filepaths of packages\n" + " -f, --files assume inputs are file paths of packages\n" " -h, --help display this help message\n" " -k, --key sort input starting on specified column\n" " -r, --reverse sort in reverse order (default: oldest to newest)\n" diff --git a/src/util/pactree.c b/src/util/pactree.c index 42c75aaf..3d55d9f1 100644 --- a/src/util/pactree.c +++ b/src/util/pactree.c @@ -310,9 +310,10 @@ static int parse_options(int argc, char *argv[]) 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" - " -a, --ascii use ascii characters for tree formatting\n" + " -a, --ascii use ASCII characters for tree formatting\n" " -b, --dbpath set an alternate database location\n" " -c, --color colorize output\n" " -d, --depth <#> limit the depth of recursion\n" @@ -320,7 +321,7 @@ static void usage(void) " -h, --help display this help message\n" " -l, --linear enable linear output\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" " --config set an alternate configuration file\n"); } diff --git a/src/util/testdb.c b/src/util/testdb.c index 0ca7ffc8..3d341b35 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -27,8 +27,6 @@ #include #include -#define BASENAME "testdb" - alpm_handle_t *handle = NULL; static void cleanup(int signum) @@ -244,11 +242,11 @@ cleanup: static void usage(void) { - fprintf(stderr, "usage:\n"); - fprintf(stderr, - "\t%s [-b ] : check the local database\n", BASENAME); - fprintf(stderr, - "\t%s [-b ] core extra ... : check the listed sync databases\n", BASENAME); + fprintf(stderr, "testdb (pacman) v" PACKAGE_VERSION "\n\n" + "Test a pacman local database for validity.\n\n" + "Usage: testdb [options]\n\n" + " -b : check the local database\n" + " -b core extra ... : check the listed sync databases\n"); exit(1); } diff --git a/src/util/testpkg.c b/src/util/testpkg.c index 10b2f2c2..d1b75ac5 100644 --- a/src/util/testpkg.c +++ b/src/util/testpkg.c @@ -22,8 +22,6 @@ #include -#define BASENAME "testpkg" - __attribute__((format(printf, 2, 0))) 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; if(argc != 2) { - fprintf(stderr, "usage: %s \n", BASENAME); + fprintf(stderr, "testpkg (pacman) v" PACKAGE_VERSION "\n\n" + "Test a pacman package for validity.\n\n" + "Usage: testpkg \n"); return 1; } diff --git a/src/util/vercmp.c b/src/util/vercmp.c index f4356fb4..41a4f8e2 100644 --- a/src/util/vercmp.c +++ b/src/util/vercmp.c @@ -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 * Copyright (c) 2002-2005 by Judd Vinet @@ -22,19 +23,19 @@ #include /* printf */ #include -#define BASENAME "vercmp" - /* forward declaration, comes from version.o in libalpm source that is linked * in directly so we don't have any library deps */ int alpm_pkg_vercmp(const char *a, const char *b); static void usage(void) { - fprintf(stderr, "usage: %s \n\n", BASENAME); - fprintf(stderr, "output values:\n"); - fprintf(stderr, " < 0 : if ver1 < ver2\n"); - fprintf(stderr, " 0 : if ver1 == ver2\n"); - fprintf(stderr, " > 0 : if ver1 > ver2\n"); + fprintf(stderr, "vercmp (pacman) v" PACKAGE_VERSION "\n\n" + "Compare package version numbers using pacman's version comparison logic.\n\n" + "Usage: vercmp \n\n" + "Output values:\n" + " < 0 : if ver1 < ver2\n" + " 0 : if ver1 == ver2\n" + " > 0 : if ver1 > ver2\n"); } int main(int argc, char *argv[]) -- cgit v1.2.3-70-g09d2