mirror of
https://github.com/google/nomulus
synced 2026-01-10 16:00:52 +00:00
Don't prompt to confirm non-mutating nomulus EPP tool commands
This is accomplished by making all non-mutating commands function with dry run set to true, which also has the pleasurable side effect of not prompting for dry-run mutating commands either, which also do nothing different/special on the second run. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=192149150
This commit is contained in:
@@ -32,7 +32,11 @@ public abstract class ConfirmingCommand implements Command {
|
||||
if (checkExecutionState()) {
|
||||
init();
|
||||
printLineIfNotEmpty(prompt());
|
||||
if (force || promptForYes("Perform this command?")) {
|
||||
if (dontRunCommand()) {
|
||||
// This typically happens when all of the work is accomplished inside of prompt(), so do
|
||||
// nothing further.
|
||||
return;
|
||||
} else if (force || promptForYes("Perform this command?")) {
|
||||
System.out.println(execute());
|
||||
printLineIfNotEmpty(postExecute());
|
||||
} else {
|
||||
@@ -49,6 +53,11 @@ public abstract class ConfirmingCommand implements Command {
|
||||
/** Initializes the command. */
|
||||
protected void init() throws Exception {}
|
||||
|
||||
/** Whether to NOT run the command. Override to true for dry-run commands. */
|
||||
protected boolean dontRunCommand() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns the optional extra confirmation prompt for the command. */
|
||||
protected String prompt() throws Exception {
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user