aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-24 14:18:07 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-24 14:18:45 +0300
commit1c92602172790bbcb75f6083cf53ce7fea25b33a (patch)
tree03e607086477a15fe9e6500cba428d8e369ae700
parent195859b3fd35819b218336f0bdd87eaa55778d56 (diff)
downloadaports-1c92602172790bbcb75f6083cf53ce7fea25b33a.tar.bz2
aports-1c92602172790bbcb75f6083cf53ce7fea25b33a.tar.xz
apk: add -i/--interactive option (fixes #60)
and use that to figure if questions are allowed or not instead of the verbosity level.
-rw-r--r--src/apk.c4
-rw-r--r--src/apk_defines.h1
-rw-r--r--src/state.c4
3 files changed, 8 insertions, 1 deletions
diff --git a/src/apk.c b/src/apk.c
index 1783eea6f2..a21427fdf2 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -37,6 +37,7 @@ static struct apk_option generic_options[] = {
required_argument, "REPO" },
{ 'q', "quiet", "Print less information" },
{ 'v', "verbose", "Print more information" },
+ { 'i', "interactive", "Ask confirmation for certain operations" },
{ 'V', "version", "Print program version and exit" },
{ 'f', "force", "Do what was asked even if it looks dangerous" },
{ 'U', "update-cache", "Update the repository cache" },
@@ -348,6 +349,9 @@ int main(int argc, char **argv)
case 'f':
apk_flags |= APK_FORCE;
break;
+ case 'i':
+ apk_flags |= APK_INTERACTIVE;
+ break;
case 'U':
apk_flags |= APK_UPDATE_CACHE;
break;
diff --git a/src/apk_defines.h b/src/apk_defines.h
index a7e13f99fe..2ce3535ff3 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -61,6 +61,7 @@ extern unsigned int apk_flags;
#define APK_UPDATE_CACHE 0x0080
#define APK_ALLOW_UNTRUSTED 0x0100
#define APK_PURGE 0x0200
+#define APK_INTERACTIVE 0x0400
#define apk_error(args...) do { apk_log("ERROR: ", args); } while (0)
#define apk_warning(args...) do { if (apk_verbosity > 0) { apk_log("WARNING: ", args); } } while (0)
diff --git a/src/state.c b/src/state.c
index f539b3b9db..16acfba2c9 100644
--- a/src/state.c
+++ b/src/state.c
@@ -667,7 +667,7 @@ int apk_state_commit(struct apk_state *state,
}
size_diff /= 1024;
- if (apk_verbosity > 1) {
+ if (apk_verbosity > 1 || (apk_flags & APK_INTERACTIVE)) {
r = dump_packages(state, cmp_remove,
"The following packages will be REMOVED");
r += dump_packages(state, cmp_downgrade,
@@ -681,6 +681,8 @@ int apk_state_commit(struct apk_state *state,
(size_diff < 0) ?
"disk space will be freed" :
"additional disk space will be used");
+ }
+ if (apk_flags & APK_INTERACTIVE) {
fprintf(stderr, "Do you want to continue [Y/n]? ");
fflush(stderr);
r = fgetc(stdin);