From 1e9a1a0292dbbf8039b8fb7536dbff2af28c7afb Mon Sep 17 00:00:00 2001 From: Artyom Date: Wed, 7 Nov 2007 01:05:33 -0600 Subject: Add -q/--quiet option for controlling output. Currently this only affects -Ss, -Sl, and -Q to output less information (only package names). In the future, we can reuse this flag for other things as well. [Aaron: rewritten as a front-end flag] Signed-off-by: Aaron Griffin [Dan: squashed commits together] Signed-off-by: Dan McGee --- src/pacman/sync.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/pacman/sync.c') diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 889c682d..58e616e7 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -262,8 +262,12 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) alpm_list_t *grp; pmpkg_t *pkg = alpm_list_getdata(j); - printf("%s/%s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg), - alpm_pkg_get_version(pkg)); + if (!config->quiet) { + printf("%s/%s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg), + alpm_pkg_get_version(pkg)); + } else { + printf("%s", alpm_pkg_get_name(pkg)); + } /* print the package size with the output if ShowSize option set */ if(config->showsize) { @@ -273,14 +277,16 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) printf(" [%.2f MB]", mbsize); } - if((grp = alpm_pkg_get_groups(pkg)) != NULL) { + if (!config->quiet) { + if((grp = alpm_pkg_get_groups(pkg)) != NULL) { group = alpm_list_getdata(grp); printf(" (%s)", (char *)alpm_list_getdata(grp)); - } + } - /* we need a newline and initial indent first */ - printf("\n "); - indentprint(alpm_pkg_get_desc(pkg), 4); + /* we need a newline and initial indent first */ + printf("\n "); + indentprint(alpm_pkg_get_desc(pkg), 4); + } printf("\n"); } /* we only want to free if the list was a search list */ @@ -448,8 +454,12 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) { pmpkg_t *pkg = alpm_list_getdata(j); - printf("%s %s %s\n", alpm_db_get_name(db), alpm_pkg_get_name(pkg), - alpm_pkg_get_version(pkg)); + if (!config->quiet) { + printf("%s %s %s\n", alpm_db_get_name(db), alpm_pkg_get_name(pkg), + alpm_pkg_get_version(pkg)); + } else { + printf("%s\n", alpm_pkg_get_name(pkg)); + } } } -- cgit v1.2.3-24-g4f1b