xbps-query: fix printing the alternatives obj.

This commit is contained in:
Juan RP 2015-10-30 14:10:01 +01:00
parent 802158e324
commit f73461a854

View File

@ -88,6 +88,8 @@ print_value_obj(const char *keyname, xbps_object_t obj,
} }
break; break;
case XBPS_TYPE_DICTIONARY: case XBPS_TYPE_DICTIONARY:
if (!raw)
printf("%s%s%s%s:\n", indent, bold, keyname, reset);
allkeys = xbps_dictionary_all_keys(obj); allkeys = xbps_dictionary_all_keys(obj);
for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) { for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
keysym = xbps_array_get(allkeys, i); keysym = xbps_array_get(allkeys, i);
@ -131,6 +133,7 @@ show_pkg_info_one(xbps_dictionary_t d, const char *keys)
const char *bold, *reset; const char *bold, *reset;
char *key, *p, *saveptr; char *key, *p, *saveptr;
int v_tty = isatty(STDOUT_FILENO); int v_tty = isatty(STDOUT_FILENO);
bool raw;
if (v_tty) { if (v_tty) {
bold = _BOLD; bold = _BOLD;
@ -144,7 +147,10 @@ show_pkg_info_one(xbps_dictionary_t d, const char *keys)
obj = xbps_dictionary_get(d, keys); obj = xbps_dictionary_get(d, keys);
if (obj == NULL) if (obj == NULL)
return; return;
print_value_obj(keys, obj, NULL, bold, reset, true); raw = true;
if (xbps_object_type(obj) == XBPS_TYPE_DICTIONARY)
raw = false;
print_value_obj(keys, obj, NULL, bold, reset, raw);
return; return;
} }
key = strdup(keys); key = strdup(keys);
@ -155,7 +161,10 @@ show_pkg_info_one(xbps_dictionary_t d, const char *keys)
obj = xbps_dictionary_get(d, p); obj = xbps_dictionary_get(d, p);
if (obj == NULL) if (obj == NULL)
continue; continue;
print_value_obj(p, obj, NULL, bold, reset, true); raw = true;
if (xbps_object_type(obj) == XBPS_TYPE_DICTIONARY)
raw = false;
print_value_obj(p, obj, NULL, bold, reset, raw);
} }
free(key); free(key);
} }