[pacman-dev] [PATCH] Improve --help switch output for pacman utils

Jason St. John jstjohn at purdue.edu
Tue Sep 3 15:20:50 EDT 2013


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 at purdue.edu>
---
This is a resubmit of a previous patch that has been rebased on the
latest master.

The original patch can be found on the ML here:
https://mailman.archlinux.org/pipermail/pacman-dev/2013-July/017647.html

This patch partially addresses the issues raised by Karol Błażewicz in
this email:
https://mailman.archlinux.org/pipermail/pacman-dev/2013-June/017391.html

 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(-)

diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index 4f34435..b13d770 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -24,8 +24,6 @@
 #include <alpm.h>
 #include <alpm_list.h>

-#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 <pacman db>] 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 <pacman db>       core extra ... : check the listed sync databases\n");
 	exit(1);
 }

diff --git a/src/util/pacsort.c b/src/util/pacsort.c
index 7c551c2..687e558 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 <index>       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 42c75aa..3d55d9f 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 <path>  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 <path>  set an alternate configuration file\n");
 }
diff --git a/src/util/testdb.c b/src/util/testdb.c
index 0ca7ffc..3d341b3 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -27,8 +27,6 @@
 #include <alpm.h>
 #include <alpm_list.h>

-#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 <pacman db>]                : check the local database\n", BASENAME);
-	fprintf(stderr,
-			"\t%s [-b <pacman db>] 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 <pacman db>                : check the local database\n"
+			"  -b <pacman db> core extra ... : check the listed sync databases\n");
 	exit(1);
 }

diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index 10b2f2c..d1b75ac 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -22,8 +22,6 @@

 #include <alpm.h>

-#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 <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;
 	}

diff --git a/src/util/vercmp.c b/src/util/vercmp.c
index f4356fb..41a4f8e 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 <pacman-dev at archlinux.org>
  *  Copyright (c) 2002-2005 by Judd Vinet <jvinet at zeroflux.org>
@@ -22,19 +23,19 @@
 #include <stdio.h> /* printf */
 #include <string.h>

-#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 <ver1> <ver2>\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 <ver1> <ver2>\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[])
--
1.8.4



More information about the pacman-dev mailing list