| | |
| | | private BooleanArgument force; |
| | | private BooleanArgument quietMode; |
| | | private BooleanArgument verbose; |
| | | private BooleanArgument acceptLicense; |
| | | |
| | | |
| | | // The argument which should be used to request usage information. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Force the upgrade. All answers will be forced to 'yes'. |
| | | * Force the upgrade. All critical questions will be forced to 'yes'. |
| | | * |
| | | * @return {@code true} if the upgrade process is forced. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Force to ignore the errors during the upgrade process. |
| | | * Continues rather than fails. |
| | | * |
| | | * @return {@code true} if the errors are forced to be ignored. |
| | | */ |
| | |
| | | return ignoreErrors.isPresent(); |
| | | } |
| | | |
| | | /** |
| | | * Automatically accepts the license if it's present. |
| | | * |
| | | * @return {@code true} if license is accepted by default. |
| | | */ |
| | | public boolean isAcceptLicense() |
| | | { |
| | | return acceptLicense.isPresent(); |
| | | } |
| | | |
| | | // Displays the provided message followed by a help usage reference. |
| | | private void displayMessageAndUsageReference(final Message message) |
| | | { |
| | |
| | | OPTION_LONG_FORCE_UPGRADE, |
| | | INFO_UPGRADE_OPTION_FORCE.get(OPTION_LONG_NO_PROMPT)); |
| | | |
| | | acceptLicense = new BooleanArgument(OPTION_LONG_ACCEPT_LICENSE, null, |
| | | OPTION_LONG_ACCEPT_LICENSE, INFO_OPTION_ACCEPT_LICENSE.get()); |
| | | |
| | | showUsageArgument = |
| | | new BooleanArgument("help", OPTION_SHORT_HELP, OPTION_LONG_HELP, |
| | | INFO_DESCRIPTION_USAGE.get()); |
| | | |
| | | |
| | | // Register the global arguments. |
| | | parser.addGlobalArgument(showUsageArgument); |
| | | parser.setUsageArgument(showUsageArgument, this.getOutputStream()); |
| | |
| | | parser.addGlobalArgument(quietMode); |
| | | parser.addGlobalArgument(force); |
| | | parser.addGlobalArgument(ignoreErrors); |
| | | parser.addGlobalArgument(acceptLicense); |
| | | |
| | | globalArgumentsInitialized = true; |
| | | } |
| | |
| | | catch (ClientException ex) |
| | | { |
| | | LOG.log(SEVERE, ex.getMessage()); |
| | | println(ERROR, ex.getMessageObject(), 0); |
| | | println(Style.ERROR, ex.getMessageObject(), 0); |
| | | |
| | | return ex.getExitCode(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LOG.log(SEVERE, ex.getMessage()); |
| | | println(ERROR, ERR_UPGRADE_MAIN_UPGRADE_PROCESS.get(ex.getMessage()), 0); |
| | | println(Style.ERROR, ERR_UPGRADE_MAIN_UPGRADE_PROCESS.get(ex |
| | | .getMessage()), 0); |
| | | |
| | | return EXIT_CODE_ERROR; |
| | | } |
| | |
| | | switch (fnc.getMessageSubType()) |
| | | { |
| | | case TITLE_CALLBACK: |
| | | println(TITLE, Message.raw(fnc.getMessage()), 0); |
| | | println(Style.TITLE, Message.raw(fnc.getMessage()), 0); |
| | | break; |
| | | case SUBTITLE_CALLBACK: |
| | | println(SUBTITLE, Message.raw(fnc.getMessage()), 4); |
| | | println(Style.SUBTITLE, Message.raw(fnc.getMessage()), |
| | | 4); |
| | | break; |
| | | case NOTICE_CALLBACK: |
| | | println(NOTICE, Message.raw(fnc.getMessage()), 0); |
| | | println(Style.NOTICE, Message.raw(fnc.getMessage()), 0); |
| | | break; |
| | | default: |
| | | LOG.log(SEVERE, "Unsupported message type: " |
| | |
| | | { |
| | | if (!isInteractive() && !isForceUpgrade()) |
| | | { |
| | | println(ERROR, ERR_UPGRADE_USER_INTERACTION_REQUIRED.get( |
| | | OPTION_LONG_NO_PROMPT, OPTION_LONG_FORCE_UPGRADE), 0); |
| | | println(Style.ERROR, ERR_UPGRADE_USER_INTERACTION_REQUIRED |
| | | .get(OPTION_LONG_NO_PROMPT, OPTION_LONG_FORCE_UPGRADE), 0); |
| | | cc.setSelectedIndex(ConfirmationCallback.NO); |
| | | return; |
| | | } |
| | |
| | | { |
| | | if (!isInteractive() && !isForceUpgrade()) |
| | | { |
| | | println(ERROR, ERR_UPGRADE_USER_INTERACTION_REQUIRED.get( |
| | | OPTION_LONG_NO_PROMPT, OPTION_LONG_FORCE_UPGRADE), 0); |
| | | println(Style.ERROR, ERR_UPGRADE_USER_INTERACTION_REQUIRED |
| | | .get(OPTION_LONG_NO_PROMPT, OPTION_LONG_FORCE_UPGRADE), 0); |
| | | cc.setSelectedIndex(ConfirmationCallback.NO); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | // Does the user specify the ignore errors mode ? |
| | | if(opt == IGNORE_ERRORS_MODE) { |
| | | if (opt == IGNORE_ERRORS_MODE) { |
| | | if (!isIgnoreErrors()) |
| | | { |
| | | cc.setSelectedIndex(ConfirmationCallback.NO); |
| | |
| | | } |
| | | cc.setSelectedIndex(ConfirmationCallback.YES); |
| | | } |
| | | |
| | | if (opt == ACCEPT_LICENSE_MODE) { |
| | | if (!isAcceptLicense()) |
| | | { |
| | | cc.setSelectedIndex(ConfirmationCallback.NO); |
| | | return; |
| | | } |
| | | cc.setSelectedIndex(ConfirmationCallback.YES); |
| | | } |
| | | } |
| | | return; |
| | | } |
| | |
| | | String value = null; |
| | | try |
| | | { |
| | | value = readInput(Message.raw(prompt), defaultOption, SUBTITLE); |
| | | value = |
| | | readInput(Message.raw(prompt), defaultOption, |
| | | Style.SUBTITLE); |
| | | } |
| | | catch (CLIException e) |
| | | { |
| | |
| | | // Displays the prompt |
| | | prompt.append(" ").append( |
| | | UpgradeContext.getDefaultOption(cc.getSelectedIndex())); |
| | | println(SUBTITLE, Message.raw(prompt), 0); |
| | | println(Style.SUBTITLE, Message.raw(prompt), 0); |
| | | LOG.log(INFO, UpgradeContext.getDefaultOption(cc.getSelectedIndex())); |
| | | } |
| | | } |