for (Entry<String, List<Problem>> entry: locationGroup.entrySet()) { AnsiUi.problemLocation(entry.getKey()); for (Problem problem : entry.getValue()) { Severity severity = problem.getSeverity(); case FATAL: case ERROR: AnsiUi.error(message); break; case WARNING: AnsiUi.warning(message); break; default: AnsiUi.remediation(remediation); AnsiUi.remediation("Options include: "); options.forEach(AnsiUi::listRemediation); AnsiUi.raw("");
private static void showRandomFailureMessage() { if (ThreadLocalRandom.current().nextInt(0, 100) < 5) { int index = ThreadLocalRandom.current().nextInt(0, failureMessages.length); String message = failureMessages[index]; AnsiUi.failure(message); } }
@Override protected void executeThis() { List<ArtifactTemplate> templates = getArtifactTemplates(); if (templates.isEmpty()) { AnsiUi.success("No configured artifact templates."); } else { AnsiUi.success("Artifact templates:"); templates.forEach(template -> AnsiUi.listItem(template.getName())); } } }
jc.parse(args); } catch (IllegalArgumentException e) { AnsiUi.error("Illegal argument: " + e.getMessage()); System.exit(1); } catch (ParameterException e) { hal.execute(); } catch (IllegalArgumentException e) { AnsiUi.error("Illegal argument: " + e.getMessage()); System.exit(1); } catch (Exception e) { AnsiUi.error(e.getMessage()); AnsiUi.remediation("That wasn't supposed to happen.\nPlease report an issue on https://github.com/spinnaker/halyard/issues"); System.exit(1);
if (options != null) { List<String> available = options(translateFieldName(options)); AnsiUi.raw(String.join(" ", available)); } else { executeThis(); AnsiUi.error(e.getCause().getMessage()); AnsiUi.remediation("Is your daemon running?"); System.exit(1); AnsiUi.error(e.getMessage()); AnsiUi.remediation("Try the command again with the --debug flag."); System.exit(1); } catch (TaskKilledException e) { AnsiUi.failure(e.getMessage()); System.exit(7); } catch (ExpectedDaemonFailureException e) { showRandomFailureMessage(); AnsiUi.failure(e.getMessage()); if (GlobalOptions.getGlobalOptions().isDebug()) { e.printStackTrace(); e.printStackTrace(); } else { AnsiUi.error(e.getMessage());
paragraphBuilder.addSnippet(action.getScriptPath()).addStyle(AnsiStyle.UNDERLINE); AnsiUi.raw(storyBuilder.toString()); } else { List<String> command = new ArrayList<>(); status = executor.backoffWait(jobId); } catch (InterruptedException e) { AnsiUi.failure("Interrupted."); System.exit(1); AnsiUi.error("Error encountered running script. See above output for more details."); System.exit(1);
@Override protected void executeThis() { deleteMaster(getMasterName()); AnsiUi.success("Deleted " + getMasterName()); }
@Override protected void executeThis() { AnsiUi.raw("Halyard Daemon Response: " + Daemon.shutdown()); } }
/** * This recursively walks the chain of subcommands, until it finds the last in the chain, and runs executeThis. * * @see NestableCommand#executeThis() */ public void execute() { String subCommand = commander.getParsedCommand(); if (subCommand == null) { if (help) { showHelp(); } else { if (this instanceof DeprecatedCommand) { AnsiUi.warning("This command is deprecated."); AnsiUi.warning(((DeprecatedCommand) this).getDeprecatedWarning()); } if (this instanceof ProtectedCommand && !GlobalOptions.getGlobalOptions().isQuiet()) { String prompt = ((ProtectedCommand) this).getPrompt(); Console console = System.console(); String input = console.readLine(prompt + " Do you want to continue? (y/N) "); if (!input.equalsIgnoreCase("y")) { AnsiUi.raw("Aborted."); return; } } safeExecuteThis(); } } else { subcommands.get(subCommand).execute(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); DeploymentConfiguration deploymentConfiguration = new OperationHandler<DeploymentConfiguration>() .setOperation(Daemon.getDeploymentConfiguration(currentDeployment, false)) .setFailureMesssage("Failed to get your deployment configuration for edits.") .get(); int hash = deploymentConfiguration.hashCode(); deploymentConfiguration.setTimezone(isSet(timezone) ? timezone : deploymentConfiguration.getTimezone()); if (deploymentConfiguration.hashCode() == hash) { AnsiUi.error("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setDeploymentConfiguration(currentDeployment, !noValidate, deploymentConfiguration)) .setFailureMesssage("Failed to apply edits to your deployment configuration") .setSuccessMessage("Successfully edited your deployment configuration") .get(); } }
if (options != null) { List<String> available = options(translateFieldName(options)); AnsiUi.raw(String.join(" ", available)); } else { executeThis(); AnsiUi.error(e.getCause().getMessage()); AnsiUi.remediation("Is your daemon running?"); System.exit(1); AnsiUi.error(e.getMessage()); AnsiUi.remediation("Try the command again with the --debug flag."); System.exit(1); } catch (TaskKilledException e) { AnsiUi.failure(e.getMessage()); System.exit(7); } catch (ExpectedDaemonFailureException e) { showRandomFailureMessage(); AnsiUi.failure(e.getMessage()); if (GlobalOptions.getGlobalOptions().isDebug()) { e.printStackTrace(); e.printStackTrace(); } else { AnsiUi.error(e.getMessage());
paragraphBuilder.addSnippet(action.getScriptPath()).addStyle(AnsiStyle.UNDERLINE); AnsiUi.raw(storyBuilder.toString()); } else { List<String> command = new ArrayList<>(); status = executor.backoffWait(jobId); } catch (InterruptedException e) { AnsiUi.failure("Interrupted."); System.exit(1); AnsiUi.error("Error encountered running script. See above output for more details."); System.exit(1);
@Override protected void executeThis() { AnsiUi.success(AnsiFormatUtils.format(getAccount(getAccountName()))); }
@Override protected void executeThis() { AnsiUi.raw("Halyard Daemon Response: " + Daemon.shutdown()); } }
/** * This recursively walks the chain of subcommands, until it finds the last in the chain, and runs executeThis. * * @see NestableCommand#executeThis() */ public void execute() { String subCommand = commander.getParsedCommand(); if (subCommand == null) { if (help) { showHelp(); } else { if (this instanceof DeprecatedCommand) { AnsiUi.warning("This command is deprecated."); AnsiUi.warning(((DeprecatedCommand) this).getDeprecatedWarning()); } if (this instanceof ProtectedCommand && !GlobalOptions.getGlobalOptions().isQuiet()) { String prompt = ((ProtectedCommand) this).getPrompt(); Console console = System.console(); String input = console.readLine(prompt + " Do you want to continue? (y/N) "); if (!input.equalsIgnoreCase("y")) { AnsiUi.raw("Aborted."); return; } } safeExecuteThis(); } } else { subcommands.get(subCommand).execute(); } }
jc.parse(args); } catch (IllegalArgumentException e) { AnsiUi.error("Illegal argument: " + e.getMessage()); System.exit(1); } catch (ParameterException e) { hal.execute(); } catch (IllegalArgumentException e) { AnsiUi.error("Illegal argument: " + e.getMessage()); System.exit(1); } catch (Exception e) { AnsiUi.error(e.getMessage()); AnsiUi.remediation("That wasn't supposed to happen.\nPlease report an issue on https://github.com/spinnaker/halyard/issues"); System.exit(1);
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); DeploymentConfiguration deploymentConfiguration = new OperationHandler<DeploymentConfiguration>() .setOperation(Daemon.getDeploymentConfiguration(currentDeployment, false)) .setFailureMesssage("Failed to get your deployment configuration for edits.") .get(); int hash = deploymentConfiguration.hashCode(); deploymentConfiguration.setTimezone(isSet(timezone) ? timezone : deploymentConfiguration.getTimezone()); if (deploymentConfiguration.hashCode() == hash) { AnsiUi.error("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setDeploymentConfiguration(currentDeployment, !noValidate, deploymentConfiguration)) .setFailureMesssage("Failed to apply edits to your deployment configuration") .setSuccessMessage("Successfully edited your deployment configuration") .get(); } }
@Override protected void executeThis() { Pubsub pubsub = getPubsub(); List<Subscription> subscriptions = pubsub.getSubscriptions(); if (subscriptions.isEmpty()) { AnsiUi.success("No configured subscriptions for " + getPubsubName() + "."); } else { AnsiUi.success("Subscriptions for " + getPubsubName() + ":"); subscriptions.forEach(subscription -> AnsiUi.listItem(subscription.getName())); } } }
private static void showRandomFailureMessage() { if (ThreadLocalRandom.current().nextInt(0, 100) < 5) { int index = ThreadLocalRandom.current().nextInt(0, failureMessages.length); String message = failureMessages[index]; AnsiUi.failure(message); } }
for (Entry<String, List<Problem>> entry: locationGroup.entrySet()) { AnsiUi.problemLocation(entry.getKey()); for (Problem problem : entry.getValue()) { Severity severity = problem.getSeverity(); case FATAL: case ERROR: AnsiUi.error(message); break; case WARNING: AnsiUi.warning(message); break; default: AnsiUi.remediation(remediation); AnsiUi.remediation("Options include: "); options.forEach(AnsiUi::listRemediation); AnsiUi.raw("");