summaryrefslogtreecommitdiffstats
path: root/src/pacman/sync.c
diff options
context:
space:
mode:
authorChantry Xavier <shiningxc@gmail.com>2008-02-19 00:44:09 +0100
committerDan McGee <dan@archlinux.org>2008-02-25 01:17:49 +0100
commit143135e666f5564240868810f0b8f4bc46ff87b5 (patch)
treed70bb426c06e9ee0dc94481ed5144aedca0bc54c /src/pacman/sync.c
parentca1a187131d95604ff2c33df3c1ec80ef4af789b (diff)
downloadpacman-143135e666f5564240868810f0b8f4bc46ff87b5.tar.gz
pacman-143135e666f5564240868810f0b8f4bc46ff87b5.tar.xz
Improve yesno function.
Add a preset paramater to yesno function saying which answer should be the default. Ref: http://www.archlinux.org/pipermail/pacman-dev/2007-June/008470.html This allows us to answer no by default to some questions, like the -Scc one mentioned in the above thread, and implemented by this patch. Another advantage is that we don't have to repeat the [Y/n] in every questions. It's only put once in yesno function. This highly reduces the chances that YES and NO strings are translated, but not some questions, which lead to obvious confusions. Finally, the noconfirm variable only needs to be used in that yesno function. So all other usages of it were removed. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Diffstat (limited to 'src/pacman/sync.c')
-rw-r--r--src/pacman/sync.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 5cf146b6..2dbf3f25 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -89,7 +89,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) {
/* We have a directory that doesn't match any syncdb.
* Ask the user if he wants to remove it. */
if(!found) {
- if(!yesno(_("Do you want to remove %s? [Y/n] "), path)) {
+ if(!yesno(1, _("Do you want to remove %s?"), path)) {
continue;
}
@@ -108,7 +108,7 @@ static int sync_cleandb_all(void) {
char newdbpath[PATH_MAX];
printf(_("Database directory: %s\n"), dbpath);
- if(!yesno(_("Do you want to remove unused repositories? [Y/n] "))) {
+ if(!yesno(1, _("Do you want to remove unused repositories?"))) {
return(0);
}
/* The sync dbs were previously put in dbpath/, but are now in dbpath/sync/,
@@ -138,7 +138,7 @@ static int sync_cleancache(int level)
* package and see if it has an entry in the local DB; if not, delete it.
*/
printf(_("Cache directory: %s\n"), cachedir);
- if(!yesno(_("Do you want to remove uninstalled packages from cache? [Y/n] "))) {
+ if(!yesno(1, _("Do you want to remove uninstalled packages from cache?"))) {
return(0);
}
printf(_("removing old packages from cache... "));
@@ -185,7 +185,7 @@ static int sync_cleancache(int level)
} else {
/* full cleanup */
printf(_("Cache directory: %s\n"), cachedir);
- if(!yesno(_("Do you want to remove ALL packages from cache? [Y/n] "))) {
+ if(!yesno(0, _("Do you want to remove ALL packages from cache?"))) {
return(0);
}
printf(_("removing all packages from cache... "));
@@ -545,8 +545,8 @@ static int sync_trans(alpm_list_t *targets)
if(strcmp("pacman", alpm_pkg_get_name(spkg)) == 0) {
printf("\n");
printf(_(":: pacman has detected a newer version of itself.\n"));
- if(yesno(_(":: Do you want to cancel the current operation\n"
- ":: and install the new pacman version now? [Y/n] "))) {
+ if(yesno(1, _(":: Do you want to cancel the current operation\n"
+ ":: and install the new pacman version now?"))) {
if(sync_trans_release() == -1) {
return(1);
}
@@ -597,14 +597,14 @@ static int sync_trans(alpm_list_t *targets)
const alpm_list_t *grppkgs = alpm_grp_get_pkgs(grp);
alpm_list_t *pkgs = alpm_list_remove_dupes(grppkgs);
list_display(" ", pkgs);
- if(yesno(_(":: Install whole content? [Y/n] "))) {
+ if(yesno(1, _(":: Install whole content?"))) {
for(k = pkgs; k; k = alpm_list_next(k)) {
targets = alpm_list_add(targets, strdup(alpm_list_getdata(k)));
}
} else {
for(k = pkgs; k; k = alpm_list_next(k)) {
char *pkgname = alpm_list_getdata(k);
- if(yesno(_(":: Install %s from group %s? [Y/n] "), pkgname, targ)) {
+ if(yesno(1, _(":: Install %s from group %s?"), pkgname, targ)) {
targets = alpm_list_add(targets, strdup(pkgname));
}
}
@@ -693,19 +693,9 @@ static int sync_trans(alpm_list_t *targets)
printf("\n");
if(config->op_s_downloadonly) {
- if(config->noconfirm) {
- printf(_("Beginning download...\n"));
- confirm = 1;
- } else {
- confirm = yesno(_("Proceed with download? [Y/n] "));
- }
+ confirm = yesno(1, _("Proceed with download?"));
} else {
- if(config->noconfirm) {
- printf(_("Beginning upgrade process...\n"));
- confirm = 1;
- } else {
- confirm = yesno(_("Proceed with installation? [Y/n] "));
- }
+ confirm = yesno(1, _("Proceed with installation?"));
}
if(!confirm) {
goto cleanup;