xbps-{bin,repo}: print with correct indentation.
--HG-- extra : convert_revision : be65d8b98702e23eaeac6ff2adb2e726824b64f7
This commit is contained in:
parent
679117e9a9
commit
92d2087c7e
2 changed files with 41 additions and 13 deletions
|
@ -129,9 +129,10 @@ xbps_remove_pkg(const char *pkgname)
|
||||||
reqby = prop_dictionary_get(dict, "requiredby");
|
reqby = prop_dictionary_get(dict, "requiredby");
|
||||||
if (reqby != NULL && prop_array_count(reqby) > 0) {
|
if (reqby != NULL && prop_array_count(reqby) > 0) {
|
||||||
printf("WARNING! %s-%s is required by the following "
|
printf("WARNING! %s-%s is required by the following "
|
||||||
"packages:\n", pkgname, version);
|
"packages:\n\n", pkgname, version);
|
||||||
(void)xbps_callback_array_iter_in_dict(dict,
|
(void)xbps_callback_array_iter_in_dict(dict,
|
||||||
"requiredby", list_strings_in_array, NULL);
|
"requiredby", list_strings_in_array, NULL);
|
||||||
|
printf("\n\n");
|
||||||
if (xbps_noyes("Do you want to remove %s?", pkgname) == false) {
|
if (xbps_noyes("Do you want to remove %s?", pkgname) == false) {
|
||||||
printf("Cancelling!\n");
|
printf("Cancelling!\n");
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
|
@ -42,12 +42,13 @@ struct show_files_cb {
|
||||||
static void show_pkg_info(prop_dictionary_t);
|
static void show_pkg_info(prop_dictionary_t);
|
||||||
static int show_pkg_files(prop_object_t, void *, bool *);
|
static int show_pkg_files(prop_object_t, void *, bool *);
|
||||||
static int show_pkg_namedesc(prop_object_t, void *, bool *);
|
static int show_pkg_namedesc(prop_object_t, void *, bool *);
|
||||||
|
static int list_strings_sep_in_array(prop_object_t, void *, bool *);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_pkg_info(prop_dictionary_t dict)
|
show_pkg_info(prop_dictionary_t dict)
|
||||||
{
|
{
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
const char *sep = NULL;
|
const char *sep;
|
||||||
char size[64];
|
char size[64];
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
|
@ -107,27 +108,26 @@ show_pkg_info(prop_dictionary_t dict)
|
||||||
obj = prop_dictionary_get(dict, "run_depends");
|
obj = prop_dictionary_get(dict, "run_depends");
|
||||||
if (obj && prop_object_type(obj) == PROP_TYPE_ARRAY) {
|
if (obj && prop_object_type(obj) == PROP_TYPE_ARRAY) {
|
||||||
printf("Dependencies:\n");
|
printf("Dependencies:\n");
|
||||||
sep = "\t";
|
(void)xbps_callback_array_iter_in_dict(dict, "run_depends",
|
||||||
xbps_callback_array_iter_in_dict(dict, "run_depends",
|
list_strings_in_array, NULL);
|
||||||
list_strings_in_array, (void *)sep);
|
printf("\n\n");
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = prop_dictionary_get(dict, "conf_files");
|
obj = prop_dictionary_get(dict, "conf_files");
|
||||||
if (obj && prop_object_type(obj) == PROP_TYPE_ARRAY) {
|
if (obj && prop_object_type(obj) == PROP_TYPE_ARRAY) {
|
||||||
printf("Configuration files:\n");
|
printf("Configuration files:\n");
|
||||||
sep = "\t";
|
sep = " ";
|
||||||
xbps_callback_array_iter_in_dict(dict, "conf_files",
|
(void)xbps_callback_array_iter_in_dict(dict, "conf_files",
|
||||||
list_strings_in_array, (void *)sep);
|
list_strings_sep_in_array, (void *)sep);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = prop_dictionary_get(dict, "keep_dirs");
|
obj = prop_dictionary_get(dict, "keep_dirs");
|
||||||
if (obj && prop_object_type(obj) == PROP_TYPE_ARRAY) {
|
if (obj && prop_object_type(obj) == PROP_TYPE_ARRAY) {
|
||||||
printf("Permanent directories:\n");
|
printf("Permanent directories:\n");
|
||||||
sep = "\t";
|
sep = " ";
|
||||||
xbps_callback_array_iter_in_dict(dict, "keep_dirs",
|
(void)xbps_callback_array_iter_in_dict(dict, "keep_dirs",
|
||||||
list_strings_in_array, (void *)sep);
|
list_strings_sep_in_array, (void *)sep);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,9 +358,36 @@ show_pkg_namedesc(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
int
|
int
|
||||||
list_strings_in_array(prop_object_t obj, void *arg, bool *loop_done)
|
list_strings_in_array(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
{
|
{
|
||||||
const char *sep = arg;
|
static size_t cols;
|
||||||
|
static bool first;
|
||||||
|
|
||||||
(void)arg;
|
(void)arg;
|
||||||
(void)loop_done;
|
(void)loop_done;
|
||||||
|
|
||||||
|
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
||||||
|
|
||||||
|
cols += strlen(prop_string_cstring_nocopy(obj)) + 4;
|
||||||
|
if (cols <= 80) {
|
||||||
|
if (first == false) {
|
||||||
|
printf(" ");
|
||||||
|
first = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("\n ");
|
||||||
|
cols = strlen(prop_string_cstring_nocopy(obj)) + 4;
|
||||||
|
}
|
||||||
|
printf("%s ", prop_string_cstring_nocopy(obj));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
list_strings_sep_in_array(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
|
{
|
||||||
|
const char *sep = arg;
|
||||||
|
|
||||||
|
(void)loop_done;
|
||||||
|
|
||||||
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
||||||
|
|
||||||
printf("%s%s\n", sep ? sep : "", prop_string_cstring_nocopy(obj));
|
printf("%s%s\n", sep ? sep : "", prop_string_cstring_nocopy(obj));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue