Skip to content

Commit

Permalink
Adding prompt confirmation while installing addons
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jan 7, 2014
1 parent 4aa8d4f commit e809b65
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion bootstrap/src/main/java/org/jboss/forge/bootstrap/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class Bootstrap

private final Furnace furnace;
private boolean exitAfter = false;
private boolean confirmAction = true;

public static void main(final String[] args)
{
Expand Down Expand Up @@ -134,6 +135,10 @@ else if ("--version".equals(args[i]) || "-v".equals(args[i]))
System.out.println("Forge version " + AddonRepositoryImpl.getRuntimeAPIVersion());
exitAfter = true;
}
else if ("-y".equals(args[i]))
{
confirmAction = false;
}
else
System.out.println("Unknown option: " + args[i]);
}
Expand Down Expand Up @@ -223,10 +228,20 @@ private void install(String addonCoordinates)
}
}

// FIXME: May prompt for confirmation
AddonActionRequest request = addonManager.install(addon);
System.out.println(request);
if (confirmAction)
{
String result = System.console().readLine("Is that correct [y/N]? ");
if (!"Y".equalsIgnoreCase(result.trim()))
{
System.out.println("Ignoring installation...");
return;
}
}
request.perform();
System.out.println("Installation successfully performed.");
System.out.println();
}
catch (Exception e)
{
Expand Down

0 comments on commit e809b65

Please sign in to comment.