summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2016-11-07 17:14:59 +0100
committerFranck Bui <fbui@suse.com>2016-11-17 18:16:50 +0100
commitd172b175f6d43d68929975e3baa3837da677bc68 (patch)
treee15fea1347829f66f7f6fdd75eef6a2e7c15f5d0 /src
parent2bcd3c26fe2a21cf1541a2850350194b3cdf5e83 (diff)
core: rework the confirmation spawn prompt
Previously it was "[Yes, Fail, Skip]" which is pretty misleading because it suggests that the whole word needs to be entered instead of a single char. Also this won't fit well when we'll extend the number of choices. This patch addresses this by changing the choice hint with "[y, f, s – h for help]" so it's now clear that a single letter has to be entered. It also introduces a new choice 'h' which describes all possible choices since a single letter can be not descriptive enough for new users. It also allow to stick with the same hint string regardless of how many choices we will support.
Diffstat (limited to 'src')
-rw-r--r--src/core/execute.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 0273b1966f..65ba9acf7a 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -739,27 +739,36 @@ static int ask_for_confirmation(const char *vc, const char *cmdline) {
goto restore_stdio;
}
- r = ask_char(&c, "yfs", "Execute %s? [Yes, Fail, Skip] ", e);
- if (r < 0) {
- write_confirm_error_fd(r, STDOUT_FILENO);
- r = CONFIRM_EXECUTE;
- goto restore_stdio;
- }
+ for (;;) {
+ r = ask_char(&c, "yfsh", "Execute %s? [y, f, s – h for help] ", e);
+ if (r < 0) {
+ write_confirm_error_fd(r, STDOUT_FILENO);
+ r = CONFIRM_EXECUTE;
+ goto restore_stdio;
+ }
- switch (c) {
- case 'f':
- printf("Failing execution.\n");
- r = CONFIRM_PRETEND_FAILURE;
- break;
- case 's':
- printf("Skipping execution.\n");
- r = CONFIRM_PRETEND_SUCCESS;
- break;
- case 'y':
- r = CONFIRM_EXECUTE;
+ switch (c) {
+ case 'f':
+ printf("Failing execution.\n");
+ r = CONFIRM_PRETEND_FAILURE;
+ break;
+ case 'h':
+ printf(" f - fail, don't execute the command and pretend it failed\n"
+ " h - help\n"
+ " s - skip, don't execute the command and pretend it succeeded\n"
+ " y - yes, execute the command\n");
+ continue;
+ case 's':
+ printf("Skipping execution.\n");
+ r = CONFIRM_PRETEND_SUCCESS;
+ break;
+ case 'y':
+ r = CONFIRM_EXECUTE;
+ break;
+ default:
+ assert_not_reached("Unhandled choice");
+ }
break;
- default:
- assert_not_reached("Unhandled choice");
}
restore_stdio: