1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-02 00:25:07 -04:00

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 <aaronmgriffin@gmail.com>
[Dan: squashed commits together]
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Artyom 2007-11-07 01:05:33 -06:00 committed by Dan McGee
parent c36b0f32c6
commit 1e9a1a0292
4 changed files with 47 additions and 19 deletions

View File

@ -26,6 +26,7 @@
typedef struct __config_t {
char *configfile;
unsigned short op;
unsigned short quiet;
unsigned short verbose;
unsigned short version;
unsigned short help;

View File

@ -112,6 +112,7 @@ static void usage(int op, const char * const myname)
printf(_(" -s, --search <regex> search locally-installed packages for matching strings\n"));
printf(_(" -t, --orphans list all packages not required by any package\n"));
printf(_(" -u, --upgrades list all packages that can be upgraded\n"));
printf(_(" -q --quiet show less information for query and search\n"));
} else if(op == PM_OP_SYNC) {
printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
printf("%s:\n", str_opt);
@ -131,6 +132,7 @@ static void usage(int op, const char * const myname)
printf(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n"));
printf(_(" --ignoregroup <grp>\n"
" ignore a group upgrade (can be used more than once)\n"));
printf(_(" -q --quiet show less information for query and search\n"));
}
printf(_(" --config <path> set an alternate configuration file\n"));
printf(_(" --logfile <path> set an alternate log file\n"));
@ -286,6 +288,7 @@ static int parseargs(int argc, char *argv[])
{"owns", no_argument, 0, 'o'},
{"file", no_argument, 0, 'p'},
{"print-uris", no_argument, 0, 'p'},
{"quiet", no_argument, 0, 'q'},
{"root", required_argument, 0, 'r'},
{"recursive", no_argument, 0, 's'},
{"search", no_argument, 0, 's'},
@ -308,7 +311,7 @@ static int parseargs(int argc, char *argv[])
{0, 0, 0, 0}
};
while((opt = getopt_long(argc, argv, "ARUFQSTr:b:vkhscVfmnoldepituwygz", opts, &option_index))) {
while((opt = getopt_long(argc, argv, "ARUFQSTr:b:vkhscVfmnoldepituwygzq", opts, &option_index))) {
alpm_list_t *list = NULL, *item = NULL; /* lists for splitting strings */
if(opt < 0) {
@ -448,6 +451,9 @@ static int parseargs(int argc, char *argv[])
config->flags |= PM_TRANS_FLAG_NOCONFLICTS;
break;
case 'y': (config->op_s_sync)++; break;
case 'q':
config->quiet = 1;
break;
case '?': return(1);
default: return(1);
}

View File

@ -146,7 +146,11 @@ static int query_search(alpm_list_t *targets)
alpm_list_t *grp;
pmpkg_t *pkg = alpm_list_getdata(i);
printf("local/%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
if (!config->quiet) {
printf("local/%s %s", 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) {
@ -156,14 +160,17 @@ static int query_search(alpm_list_t *targets)
printf(" [%.2f MB]", mbsize);
}
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);
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);
}
printf("\n");
}
@ -307,7 +314,11 @@ static void display(pmpkg_t *pkg)
dump_pkg_changelog(changelog, alpm_pkg_get_name(pkg));
}
if(!config->op_q_info && !config->op_q_list && !config->op_q_changelog) {
printf("%s %s\n", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
if (!config->quiet) {
printf("%s %s\n", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
} else {
printf("%s\n", alpm_pkg_get_name(pkg));
}
}
}

View File

@ -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));
}
}
}