info: only show package desc when --verbose
also introduce apk_verbosity. --quiet reduce verbosity and --verbose increases it. Default verbosity is 1.cute-signatures
parent
af6f329fc7
commit
50daa05773
10
src/apk.c
10
src/apk.c
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
const char *apk_root;
|
const char *apk_root;
|
||||||
const char *apk_repository = NULL;
|
const char *apk_repository = NULL;
|
||||||
int apk_quiet = 0, apk_progress = 0;
|
int apk_verbosity = 1, apk_progress = 0;
|
||||||
int apk_cwd_fd;
|
int apk_cwd_fd;
|
||||||
|
|
||||||
void apk_log(const char *prefix, const char *format, ...)
|
void apk_log(const char *prefix, const char *format, ...)
|
||||||
|
@ -95,11 +95,12 @@ static struct apk_applet *deduce_applet(int argc, char **argv)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NUM_GENERIC_OPTS 4
|
#define NUM_GENERIC_OPTS 5
|
||||||
static struct option generic_options[32] = {
|
static struct option generic_options[32] = {
|
||||||
{ "root", required_argument, NULL, 'Q' },
|
{ "root", required_argument, NULL, 'Q' },
|
||||||
{ "repository", required_argument, NULL, 'X' },
|
{ "repository", required_argument, NULL, 'X' },
|
||||||
{ "quiet", no_argument, NULL, 'q' },
|
{ "quiet", no_argument, NULL, 'q' },
|
||||||
|
{ "verbose", no_argument, NULL, 'v' },
|
||||||
{ "progress", no_argument, NULL, 0x100 },
|
{ "progress", no_argument, NULL, 0x100 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,7 +149,10 @@ int main(int argc, char **argv)
|
||||||
apk_repository = optarg;
|
apk_repository = optarg;
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
apk_quiet = 1;
|
apk_verbosity--;
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
apk_verbosity++;
|
||||||
break;
|
break;
|
||||||
case 0x100:
|
case 0x100:
|
||||||
apk_progress = 1;
|
apk_progress = 1;
|
||||||
|
|
|
@ -50,11 +50,11 @@ extern csum_t bad_checksum;
|
||||||
#define csum_valid(buf) memcmp(buf, bad_checksum, sizeof(csum_t))
|
#define csum_valid(buf) memcmp(buf, bad_checksum, sizeof(csum_t))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int apk_cwd_fd, apk_quiet, apk_progress;
|
extern int apk_cwd_fd, apk_verbosity, apk_progress;
|
||||||
|
|
||||||
#define apk_error(args...) apk_log("ERROR: ", args);
|
#define apk_error(args...) apk_log("ERROR: ", args);
|
||||||
#define apk_warning(args...) if (!apk_quiet) { apk_log("WARNING: ", args); }
|
#define apk_warning(args...) if (apk_verbosity > 0) { apk_log("WARNING: ", args); }
|
||||||
#define apk_message(args...) if (!apk_quiet) { apk_log(NULL, args); }
|
#define apk_message(args...) if (apk_verbosity > 0) { apk_log(NULL, args); }
|
||||||
|
|
||||||
void apk_log(const char *prefix, const char *format, ...);
|
void apk_log(const char *prefix, const char *format, ...);
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ static int audit_directory(apk_hash_item item, void *ctx)
|
||||||
reason = 'F';
|
reason = 'F';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (apk_quiet)
|
if (apk_verbosity < 1)
|
||||||
printf("%s\n", tmp);
|
printf("%s\n", tmp);
|
||||||
else
|
else
|
||||||
printf("%c %s\n", reason, tmp);
|
printf("%c %s\n", reason, tmp);
|
||||||
|
|
10
src/info.c
10
src/info.c
|
@ -26,8 +26,10 @@ static int info_list(struct apk_database *db, int argc, char **argv)
|
||||||
|
|
||||||
list_for_each_entry(pkg, &db->installed.packages, installed_pkgs_list) {
|
list_for_each_entry(pkg, &db->installed.packages, installed_pkgs_list) {
|
||||||
printf("%s", pkg->name->name);
|
printf("%s", pkg->name->name);
|
||||||
if (!apk_quiet)
|
if (apk_verbosity > 0)
|
||||||
printf("-%s - %s", pkg->version, pkg->description);
|
printf("-%s", pkg->version);
|
||||||
|
if (apk_verbosity > 1)
|
||||||
|
printf("- %s", pkg->description);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -66,7 +68,7 @@ static int info_who_owns(struct apk_database *db, int argc, char **argv)
|
||||||
if (pkg == NULL)
|
if (pkg == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (apk_quiet) {
|
if (apk_verbosity < 1) {
|
||||||
dep = (struct apk_dependency) {
|
dep = (struct apk_dependency) {
|
||||||
.name = pkg->name,
|
.name = pkg->name,
|
||||||
};
|
};
|
||||||
|
@ -76,7 +78,7 @@ static int info_who_owns(struct apk_database *db, int argc, char **argv)
|
||||||
pkg->name->name, pkg->version);
|
pkg->name->name, pkg->version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (apk_quiet && deps != NULL) {
|
if (apk_verbosity < 1 && deps != NULL) {
|
||||||
char buf[512];
|
char buf[512];
|
||||||
apk_deps_format(buf, sizeof(buf), deps);
|
apk_deps_format(buf, sizeof(buf), deps);
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
|
|
Loading…
Reference in New Issue