info: only show package desc when --verbose

also introduce apk_verbosity. --quiet reduce verbosity and --verbose
increases it.

Default verbosity is 1.
cute-signatures
Natanael Copa 2009-01-16 09:33:55 +00:00
parent af6f329fc7
commit 50daa05773
4 changed files with 17 additions and 11 deletions

View File

@ -23,7 +23,7 @@
const char *apk_root;
const char *apk_repository = NULL;
int apk_quiet = 0, apk_progress = 0;
int apk_verbosity = 1, apk_progress = 0;
int apk_cwd_fd;
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;
}
#define NUM_GENERIC_OPTS 4
#define NUM_GENERIC_OPTS 5
static struct option generic_options[32] = {
{ "root", required_argument, NULL, 'Q' },
{ "repository", required_argument, NULL, 'X' },
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
{ "progress", no_argument, NULL, 0x100 },
};
@ -148,7 +149,10 @@ int main(int argc, char **argv)
apk_repository = optarg;
break;
case 'q':
apk_quiet = 1;
apk_verbosity--;
break;
case 'v':
apk_verbosity++;
break;
case 0x100:
apk_progress = 1;

View File

@ -50,11 +50,11 @@ extern csum_t bad_checksum;
#define csum_valid(buf) memcmp(buf, bad_checksum, sizeof(csum_t))
#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_warning(args...) if (!apk_quiet) { apk_log("WARNING: ", args); }
#define apk_message(args...) if (!apk_quiet) { apk_log(NULL, args); }
#define apk_warning(args...) if (apk_verbosity > 0) { apk_log("WARNING: ", args); }
#define apk_message(args...) if (apk_verbosity > 0) { apk_log(NULL, args); }
void apk_log(const char *prefix, const char *format, ...);

View File

@ -75,7 +75,7 @@ static int audit_directory(apk_hash_item item, void *ctx)
reason = 'F';
}
}
if (apk_quiet)
if (apk_verbosity < 1)
printf("%s\n", tmp);
else
printf("%c %s\n", reason, tmp);

View File

@ -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) {
printf("%s", pkg->name->name);
if (!apk_quiet)
printf("-%s - %s", pkg->version, pkg->description);
if (apk_verbosity > 0)
printf("-%s", pkg->version);
if (apk_verbosity > 1)
printf("- %s", pkg->description);
printf("\n");
}
return 0;
@ -66,7 +68,7 @@ static int info_who_owns(struct apk_database *db, int argc, char **argv)
if (pkg == NULL)
continue;
if (apk_quiet) {
if (apk_verbosity < 1) {
dep = (struct apk_dependency) {
.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);
}
}
if (apk_quiet && deps != NULL) {
if (apk_verbosity < 1 && deps != NULL) {
char buf[512];
apk_deps_format(buf, sizeof(buf), deps);
printf("%s\n", buf);