[pacman-contrib] [PATCH 1/2] pacsort: Make help/version output follow std-options
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- src/pacsort.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pacsort.c b/src/pacsort.c index 6d1bf25..019f202 100644 --- a/src/pacsort.c +++ b/src/pacsort.c @@ -67,6 +67,7 @@ static struct options_t { int null; int filemode; int help; + int version; char delim; } opts; @@ -418,7 +419,7 @@ static char escape_char(const char *string) static void usage(void) { - fprintf(stderr, "pacsort (pacman) v" PACKAGE_VERSION "\n\n" + printf("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 file paths of packages\n" @@ -432,6 +433,11 @@ static void usage(void) "Standard input is read when no files are given.\n\n"); } +static void version(void) +{ + printf("pacsort v" PACKAGE_VERSION "\n"); +} + static int parse_options(int argc, char **argv) { int opt; @@ -442,6 +448,7 @@ static int parse_options(int argc, char **argv) {"key", required_argument, 0, 'k'}, {"reverse", no_argument, 0, 'r'}, {"separator", required_argument, 0, 't'}, + {"version", no_argument, 0, 'v'}, {"null", no_argument, 0, 'z'}, {0, 0, 0, 0} }; @@ -471,6 +478,9 @@ static int parse_options(int argc, char **argv) return 1; } break; + case 'v': + opts.version = 1; + return 0; case 'z': opts.null = 1; break; @@ -505,6 +515,11 @@ int main(int argc, char *argv[]) return 0; } + if(opts.version) { + version(); + return 0; + } + list = list_new(100); buffer = buffer_new(BUFSIZ * 3); -- 2.10.0
Since it's no longer part of pacman proper it doesn't follow the same versions. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- src/checkupdates.sh.in | 2 +- src/paccache.sh.in | 2 +- src/pacdiff.sh.in | 2 +- src/paclist.sh.in | 2 +- src/paclog-pkglist.sh.in | 2 +- src/pacscripts.sh.in | 2 +- src/pacsearch.pl.in | 2 +- src/pacsort.c | 2 +- src/pactree.c | 4 ++-- src/rankmirrors.sh.in | 2 +- src/updpkgsums.sh.in | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in index e76780e..4162548 100644 --- a/src/checkupdates.sh.in +++ b/src/checkupdates.sh.in @@ -25,7 +25,7 @@ m4_include(../lib/output_format.sh) m4_include(../lib/term_colors.sh) if (( $# > 0 )); then - echo "${myname} (pacman) v${myver}" + echo "${myname} v${myver}" echo echo "Safely print a list of pending updates" echo diff --git a/src/paccache.sh.in b/src/paccache.sh.in index fcdf30b..143c6e3 100644 --- a/src/paccache.sh.in +++ b/src/paccache.sh.in @@ -176,7 +176,7 @@ summarize() { usage() { cat <<EOF -${myname} (pacman) v${myver} +${myname} v${myver} A flexible pacman cache cleaning utility. diff --git a/src/pacdiff.sh.in b/src/pacdiff.sh.in index 32f8c06..ef385c2 100644 --- a/src/pacdiff.sh.in +++ b/src/pacdiff.sh.in @@ -33,7 +33,7 @@ m4_include(../lib/output_format.sh) usage() { cat <<EOF -${myname} (pacman) v${myver} +${myname} v${myver} A simple program to merge or remove pacnew/pacsave files. diff --git a/src/paclist.sh.in b/src/paclist.sh.in index f4fd540..f827dcf 100644 --- a/src/paclist.sh.in +++ b/src/paclist.sh.in @@ -31,7 +31,7 @@ if ! type gettext &>/dev/null; then fi usage() { - printf "%s (pacman) v%s\n" "${myname}" "${myver}" + printf "%s v%s\n" "${myname}" "${myver}" echo printf "List all packages installed from a given repository\n" "${myname}" echo diff --git a/src/paclog-pkglist.sh.in b/src/paclog-pkglist.sh.in index 847b389..9c137e0 100644 --- a/src/paclog-pkglist.sh.in +++ b/src/paclog-pkglist.sh.in @@ -25,7 +25,7 @@ export TEXTDOMAINDIR='/usr/share/locale' declare logfile=${1:-@localstatedir@/log/pacman.log} usage() { - printf "%s (pacman) v%s\n" "${myname}" "${myver}" + printf "%s v%s\n" "${myname}" "${myver}" echo echo "Parse a log file into a list of currently installed packages" echo diff --git a/src/pacscripts.sh.in b/src/pacscripts.sh.in index d769595..68c9441 100644 --- a/src/pacscripts.sh.in +++ b/src/pacscripts.sh.in @@ -45,7 +45,7 @@ error() { } usage() { - echo "${myname} (pacman) v${myver}" + echo "${myname} v${myver}" echo echo "Prints the {pre,post}_{install,remove,upgrade} scripts of a given package." echo diff --git a/src/pacsearch.pl.in b/src/pacsearch.pl.in index a89328d..0f6b3ea 100644 --- a/src/pacsearch.pl.in +++ b/src/pacsearch.pl.in @@ -27,7 +27,7 @@ my $myname = 'pacsearch'; my $myver = '@PACKAGE_VERSION@'; sub usage { - print "$myname (pacman) v$myver\n\n"; + print "$myname v$myver\n\n"; print "Perform a pacman search using both the local and the sync databases.\n\n"; print "Usage: $myname [-n] <pattern>\n\n"; print "Options:\n"; diff --git a/src/pacsort.c b/src/pacsort.c index 019f202..dcff76c 100644 --- a/src/pacsort.c +++ b/src/pacsort.c @@ -419,7 +419,7 @@ static char escape_char(const char *string) static void usage(void) { - printf("pacsort (pacman) v" PACKAGE_VERSION "\n\n" + printf("pacsort 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 file paths of packages\n" diff --git a/src/pactree.c b/src/pactree.c index b9d47e9..13f9e72 100644 --- a/src/pactree.c +++ b/src/pactree.c @@ -211,7 +211,7 @@ static void cleanup(int ret) static void usage(void) { - fprintf(stdout, "pactree (pacman) v" PACKAGE_VERSION "\n\n" + fprintf(stdout, "pactree 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" @@ -230,7 +230,7 @@ static void usage(void) static void version(void) { - fprintf(stdout, "pactree (pacman) v" PACKAGE_VERSION "\n"); + fprintf(stdout, "pactree v" PACKAGE_VERSION "\n"); } static int parse_options(int argc, char *argv[]) diff --git a/src/rankmirrors.sh.in b/src/rankmirrors.sh.in index 7b50eb2..a05b8e0 100644 --- a/src/rankmirrors.sh.in +++ b/src/rankmirrors.sh.in @@ -25,7 +25,7 @@ declare -r myname='rankmirrors' declare -r myver='@PACKAGE_VERSION@' usage() { - echo "${myname} (pacman) v${myver}" + echo "${myname} v${myver}" echo 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" diff --git a/src/updpkgsums.sh.in b/src/updpkgsums.sh.in index c571d29..9c545ea 100644 --- a/src/updpkgsums.sh.in +++ b/src/updpkgsums.sh.in @@ -23,7 +23,7 @@ declare -r myname='updpkgsums' declare -r myver='@PACKAGE_VERSION@' usage() { - printf "%s (pacman) v%s\n" "${myname}" "${myver}" + printf "%s v%s\n" "${myname}" "${myver}" echo printf "%s will perform an in place update of the checksums in the\n" "${myname}" echo "path specified by [build file], defaulting to PKGBUILD in the current" -- 2.10.0
participants (1)
-
Johannes Löthberg