From 3e6651d286b985d575c905fa876913b6988876ff Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 31 Oct 2015 12:11:21 +0100 Subject: [PATCH] xbps-alternatives(1): implemented -g -l. --- NEWS | 3 +++ bin/xbps-alternatives/main.c | 7 +++++-- bin/xbps-alternatives/xbps-alternatives.1 | 11 +++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 3a6edf94..2c35330e 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ xbps-0.49 (???): + * xbps-alternatives(1): -g -l now works. To only print all alternatives + associated with this group. + * xbps-remove(1): this now will print the messages from alternatives. * alternatives: do not register duplicate alternative groups. Happened when diff --git a/bin/xbps-alternatives/main.c b/bin/xbps-alternatives/main.c index 8a07c2c7..c722a74b 100644 --- a/bin/xbps-alternatives/main.c +++ b/bin/xbps-alternatives/main.c @@ -108,7 +108,7 @@ list_pkg_alternatives(xbps_dictionary_t pkgd, const char *group, bool print_key) } static int -list_alternatives(struct xbps_handle *xhp, const char *pkgname) +list_alternatives(struct xbps_handle *xhp, const char *pkgname, const char *grp) { xbps_dictionary_t alternatives, pkgd; xbps_array_t allkeys; @@ -139,6 +139,9 @@ list_alternatives(struct xbps_handle *xhp, const char *pkgname) keyname = xbps_dictionary_keysym_cstring_nocopy(keysym); array = xbps_dictionary_get_keysym(alternatives, keysym); + if (grp && strcmp(grp, keyname)) + continue; + printf("%s\n", keyname); for (unsigned int x = 0; x < xbps_array_count(array); x++) { const char *str; @@ -247,7 +250,7 @@ main(int argc, char **argv) rv = xbps_pkgdb_update(&xh, true, true); } else if (list_mode) { /* list alternative groups */ - rv = list_alternatives(&xh, pkg); + rv = list_alternatives(&xh, pkg, group); } xbps_end(&xh); diff --git a/bin/xbps-alternatives/xbps-alternatives.1 b/bin/xbps-alternatives/xbps-alternatives.1 index 784c44f4..a74a2ba1 100644 --- a/bin/xbps-alternatives/xbps-alternatives.1 +++ b/bin/xbps-alternatives/xbps-alternatives.1 @@ -1,4 +1,4 @@ -.Dd October 30, 2015 +.Dd October 31, 2015 .Dt XBPS-ALTERNATIVES 1 .Sh NAME .Nm xbps-alternatives @@ -43,9 +43,12 @@ Show the version information. .Sh MODE Only one of the following modes can be used at a time. .Bl -tag -width -x -.It Fl l, Fl -list Op PKG -Lists all current alternatives or only from -.Ar PKG . +.It Fl l, Fl -list Op PKG Op -g Ar group +Lists all current alternative groups or only from +.Ar PKG , +or just a specific group, if the +.Fl g Fl -group +option is set. .It Fl s, Fl -set Ar PKG Op -g Ar group Set alternative groups specified by .Ar PKG