summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-01-16 09:33:55 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-01-16 09:33:55 +0000
commit50daa05773a66fc94fd459011f51544b8b6e0517 (patch)
treedc9e320fd4e46923f5d8951a7e652d56e8dcec33
parentaf6f329fc72bd93d2ac1a07ce6b23e510cf82ea8 (diff)
downloadapk-tools-50daa05773a66fc94fd459011f51544b8b6e0517.tar.gz
apk-tools-50daa05773a66fc94fd459011f51544b8b6e0517.tar.bz2
apk-tools-50daa05773a66fc94fd459011f51544b8b6e0517.tar.xz
apk-tools-50daa05773a66fc94fd459011f51544b8b6e0517.zip
info: only show package desc when --verbose
also introduce apk_verbosity. --quiet reduce verbosity and --verbose increases it. Default verbosity is 1.
-rw-r--r--src/apk.c10
-rw-r--r--src/apk_defines.h6
-rw-r--r--src/audit.c2
-rw-r--r--src/info.c10
4 files changed, 17 insertions, 11 deletions
diff --git a/src/apk.c b/src/apk.c
index 2a8c959..8040dd9 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -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;
diff --git a/src/apk_defines.h b/src/apk_defines.h
index 5503167..865ec5f 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -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, ...);
diff --git a/src/audit.c b/src/audit.c
index f04b14a..c080f2f 100644
--- a/src/audit.c
+++ b/src/audit.c
@@ -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);
diff --git a/src/info.c b/src/info.c
index c981c18..1cde91d 100644
--- a/src/info.c
+++ b/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) {
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);