Search in sources :

Example 1 with Updates

use of org.jboss.galleon.cli.cmd.maingrp.CheckUpdatesCommand.Updates in project galleon by wildfly.

the class UpdateCommand method doRunCommand.

@Override
protected void doRunCommand(PmCommandInvocation session, Map<String, String> options) throws CommandExecutionException {
    try {
        ProvisioningManager mgr = getManager(session);
        Updates updates = CheckUpdatesCommand.getUpdatesTable(mgr, session, allDependencies(), getFP());
        if (updates.plan.isEmpty()) {
            session.println(UP_TO_DATE);
        } else {
            session.println(UPDATES_AVAILABLE);
            session.println(updates.t.build());
            if (!noConfirm()) {
                try {
                    Key k = null;
                    while (k == null || (!Key.y.equals(k) && !Key.n.equals(k))) {
                        session.print("Proceed with latest updates [y/n]?");
                        KeyAction a = session.input();
                        k = Key.findStartKey(a.buffer().array());
                    }
                    if (Key.n.equals(k)) {
                        return;
                    }
                } finally {
                    session.println("");
                }
            }
            mgr.apply(updates.plan, options);
        }
    } catch (ProvisioningException | IOException ex) {
        throw new CommandExecutionException(session.getPmSession(), CliErrors.updateFailed(), ex);
    } catch (InterruptedException ignored) {
    // Just exit the command smoothly
    }
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager) Updates(org.jboss.galleon.cli.cmd.maingrp.CheckUpdatesCommand.Updates) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException) KeyAction(org.aesh.readline.action.KeyAction) Key(org.aesh.readline.terminal.Key)

Aggregations

IOException (java.io.IOException)1 KeyAction (org.aesh.readline.action.KeyAction)1 Key (org.aesh.readline.terminal.Key)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ProvisioningManager (org.jboss.galleon.ProvisioningManager)1 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)1 Updates (org.jboss.galleon.cli.cmd.maingrp.CheckUpdatesCommand.Updates)1