[4/5] query: print extended data when extra info is requested

Message ID 20220206183041.104788-5-andrew.gregory.8@gmail.com
State New
Headers show
Series adding extended package data | expand

Commit Message

Andrew Gregory Feb. 6, 2022, 6:30 p.m. UTC
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
---
 src/pacman/package.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Patch

diff --git a/src/pacman/package.c b/src/pacman/package.c
index 61664f7d..886b7cac 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -351,6 +351,19 @@  void dump_pkg_full(alpm_pkg_t *pkg, int extra)
 		dump_pkg_backups(pkg, cols);
 	}
 
+	if(extra) {
+		alpm_list_t *text = NULL, *pdata = alpm_pkg_get_data(pkg);
+		while(pdata) {
+			alpm_pkg_data_t *pd = pdata->data;
+			char *formatted = NULL;
+			pm_asprintf(&formatted, "%s: %s", pd->name, pd->value);
+			text = alpm_list_add(text, formatted);
+			pdata = pdata->next;
+		}
+		list_display_linebreak("Data            :", text, cols);
+		FREELIST(text);
+	}
+
 	/* final newline to separate packages */
 	printf("\n");