xbps-query(8): -S mode prints keys with ANSI bold escape code.
This commit is contained in:
parent
0b116a0f3f
commit
c301cc32e5
3
NEWS
3
NEWS
@ -1,5 +1,8 @@
|
|||||||
xbps-0.38 (???):
|
xbps-0.38 (???):
|
||||||
|
|
||||||
|
* xbps-query(8): --show/-S mode now explicitly prints pkg metadata keys
|
||||||
|
with the bold ANSI escape code.
|
||||||
|
|
||||||
* xbps-query(8): --search --property now works with <number> objects, i.e:
|
* xbps-query(8): --search --property now works with <number> objects, i.e:
|
||||||
|
|
||||||
$ xbps-query -s '' -p filename-size
|
$ xbps-query -s '' -p filename-size
|
||||||
|
@ -36,6 +36,9 @@
|
|||||||
#include <xbps.h>
|
#include <xbps.h>
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
|
#define _BOLD "\033[1m"
|
||||||
|
#define _RESET "\033[m"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_value_obj(const char *keyname, xbps_object_t obj,
|
print_value_obj(const char *keyname, xbps_object_t obj,
|
||||||
const char *indent, bool raw)
|
const char *indent, bool raw)
|
||||||
@ -51,12 +54,12 @@ print_value_obj(const char *keyname, xbps_object_t obj,
|
|||||||
switch (xbps_object_type(obj)) {
|
switch (xbps_object_type(obj)) {
|
||||||
case XBPS_TYPE_STRING:
|
case XBPS_TYPE_STRING:
|
||||||
if (!raw)
|
if (!raw)
|
||||||
printf("%s%s: ", indent, keyname);
|
printf("%s%s%s%s: ", indent, _BOLD, keyname, _RESET);
|
||||||
printf("%s\n", xbps_string_cstring_nocopy(obj));
|
printf("%s\n", xbps_string_cstring_nocopy(obj));
|
||||||
break;
|
break;
|
||||||
case XBPS_TYPE_NUMBER:
|
case XBPS_TYPE_NUMBER:
|
||||||
if (!raw)
|
if (!raw)
|
||||||
printf("%s%s: ", indent, keyname);
|
printf("%s%s%s%s: ", indent, _BOLD, keyname, _RESET);
|
||||||
if (xbps_humanize_number(size,
|
if (xbps_humanize_number(size,
|
||||||
(int64_t)xbps_number_unsigned_integer_value(obj)) == -1)
|
(int64_t)xbps_number_unsigned_integer_value(obj)) == -1)
|
||||||
printf("%ju\n",
|
printf("%ju\n",
|
||||||
@ -66,12 +69,12 @@ print_value_obj(const char *keyname, xbps_object_t obj,
|
|||||||
break;
|
break;
|
||||||
case XBPS_TYPE_BOOL:
|
case XBPS_TYPE_BOOL:
|
||||||
if (!raw)
|
if (!raw)
|
||||||
printf("%s%s: ", indent, keyname);
|
printf("%s%s%s%s: ", indent, _BOLD, keyname, _RESET);
|
||||||
printf("%s\n", xbps_bool_true(obj) ? "yes" : "no");
|
printf("%s\n", xbps_bool_true(obj) ? "yes" : "no");
|
||||||
break;
|
break;
|
||||||
case XBPS_TYPE_ARRAY:
|
case XBPS_TYPE_ARRAY:
|
||||||
if (!raw)
|
if (!raw)
|
||||||
printf("%s%s:\n", indent, keyname);
|
printf("%s%s%s%s:\n", indent, _BOLD, keyname, _RESET);
|
||||||
for (unsigned int i = 0; i < xbps_array_count(obj); i++) {
|
for (unsigned int i = 0; i < xbps_array_count(obj); i++) {
|
||||||
obj2 = xbps_array_get(obj, i);
|
obj2 = xbps_array_get(obj, i);
|
||||||
if (xbps_object_type(obj2) == XBPS_TYPE_STRING) {
|
if (xbps_object_type(obj2) == XBPS_TYPE_STRING) {
|
||||||
@ -98,7 +101,7 @@ print_value_obj(const char *keyname, xbps_object_t obj,
|
|||||||
case XBPS_TYPE_DATA:
|
case XBPS_TYPE_DATA:
|
||||||
if (!raw) {
|
if (!raw) {
|
||||||
xbps_humanize_number(size, (int64_t)xbps_data_size(obj));
|
xbps_humanize_number(size, (int64_t)xbps_data_size(obj));
|
||||||
printf("%s%s: %s\n", indent, keyname, size);
|
printf("%s%s%s%s: %s\n", indent, _BOLD, keyname, _RESET, size);
|
||||||
} else {
|
} else {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char buf[BUFSIZ-1];
|
char buf[BUFSIZ-1];
|
||||||
@ -152,7 +155,7 @@ print_srcrevs(const char *keyname, xbps_string_t obj)
|
|||||||
const char *str = xbps_string_cstring_nocopy(obj);
|
const char *str = xbps_string_cstring_nocopy(obj);
|
||||||
|
|
||||||
/* parse string appending a \t after EOL */
|
/* parse string appending a \t after EOL */
|
||||||
printf("%s:\n ", keyname);
|
printf("%s%s%s:\n ", _BOLD, keyname, _RESET);
|
||||||
for (unsigned int i = 0; i < strlen(str); i++) {
|
for (unsigned int i = 0; i < strlen(str); i++) {
|
||||||
if (str[i] == '\n')
|
if (str[i] == '\n')
|
||||||
printf("\n ");
|
printf("\n ");
|
||||||
|
Loading…
Reference in New Issue
Block a user