diff options
author | morganamilo <morganamilo@gmail.com> | 2018-09-04 15:47:44 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2018-09-19 03:06:55 +0200 |
commit | 961ef1a4c8cfc0fa7b8da4e6cb77d8327934e32f (patch) | |
tree | 334846e05aba9595af799b59fb7b303d39ce1d47 | |
parent | 2bec380e108536f5e5f728ef66223ed3fabf5ab1 (diff) | |
download | pacman-961ef1a4c8cfc0fa7b8da4e6cb77d8327934e32f.tar.gz pacman-961ef1a4c8cfc0fa7b8da4e6cb77d8327934e32f.tar.xz |
Show group status during file search
When doing "pacman -Fs", show the "(groupname)"
message just like "pacman -Ss".
And refactor group printing to its own function.
Signed-off-by: morganamilo <morganamilo@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | src/pacman/files.c | 1 | ||||
-rw-r--r-- | src/pacman/package.c | 35 | ||||
-rw-r--r-- | src/pacman/package.h | 1 |
3 files changed, 22 insertions, 15 deletions
diff --git a/src/pacman/files.c b/src/pacman/files.c index 58cf8d3d..fa4170bd 100644 --- a/src/pacman/files.c +++ b/src/pacman/files.c @@ -162,6 +162,7 @@ static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) { colstr->title, alpm_pkg_get_name(pkg), colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor); + print_groups(pkg); print_installed(db_local, pkg); printf("\n"); diff --git a/src/pacman/package.c b/src/pacman/package.c index ee43dca7..d8880837 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -494,6 +494,25 @@ void print_installed(alpm_db_t *db_local, alpm_pkg_t *pkg) } } +void print_groups(alpm_pkg_t *pkg) +{ + alpm_list_t *grp; + if((grp = alpm_pkg_get_groups(pkg)) != NULL) { + const colstr_t *colstr = &config->colstr; + alpm_list_t *k; + printf(" %s(", colstr->groups); + for(k = grp; k; k = alpm_list_next(k)) { + const char *group = k->data; + fputs(group, stdout); + if(alpm_list_next(k)) { + /* only print a spacer if there are more groups */ + putchar(' '); + } + } + printf(")%s", colstr->nocolor); + } +} + /** * Display the details of a search. * @param db the database we're searching @@ -526,7 +545,6 @@ int dump_pkg_search(alpm_db_t *db, alpm_list_t *targets, int show_status) cols = getcols(); for(i = searchlist; i; i = alpm_list_next(i)) { - alpm_list_t *grp; alpm_pkg_t *pkg = i->data; if(config->quiet) { @@ -536,20 +554,7 @@ int dump_pkg_search(alpm_db_t *db, alpm_list_t *targets, int show_status) colstr->title, alpm_pkg_get_name(pkg), colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor); - if((grp = alpm_pkg_get_groups(pkg)) != NULL) { - alpm_list_t *k; - printf(" %s(", colstr->groups); - for(k = grp; k; k = alpm_list_next(k)) { - const char *group = k->data; - fputs(group, stdout); - if(alpm_list_next(k)) { - /* only print a spacer if there are more groups */ - putchar(' '); - } - } - printf(")%s", colstr->nocolor); - } - + print_groups(pkg); if(show_status) { print_installed(db_local, pkg); } diff --git a/src/pacman/package.h b/src/pacman/package.h index 68c2a630..03e1afa0 100644 --- a/src/pacman/package.h +++ b/src/pacman/package.h @@ -29,6 +29,7 @@ void dump_pkg_files(alpm_pkg_t *pkg, int quiet); void dump_pkg_changelog(alpm_pkg_t *pkg); void print_installed(alpm_db_t *db_local, alpm_pkg_t *pkg); +void print_groups(alpm_pkg_t *pkg); int dump_pkg_search(alpm_db_t *db, alpm_list_t *targets, int show_status); #endif /* PM_PACKAGE_H */ |