Source:
@Override public void run(Bootstrap<KeywhizConfig> bootstrap, Namespace namespace, KeywhizConfig config) { String deletedBeforeStr = namespace.getString(INPUT_DELETED_BEFORE); DateTime deletedBefore = getDateIfValid(deletedBeforeStr); if (deletedBefore == null) { return; } Integer sleepMillis = namespace.getInt(INPUT_SLEEP_MILLIS); if (sleepMillis < 0) { System.out.format("Milliseconds to sleep must be nonnegative; got %d", sleepMillis); return; } long affectedCount = secretDAO.countSecretsDeletedBeforeDate(deletedBefore); System.out.format( "WARNING: This will PERMANENTLY remove all secrets deleted before %s. %d secrets will be removed. Confirm? (y/n)\n", deletedBefore.toString(), affectedCount); String confirm; if (System.console() != null) { Console console = System.console(); confirm = console.readLine(); } else { Scanner scanner = new Scanner(System.in); confirm = scanner.nextLine(); } if (confirm == null || !(confirm.equalsIgnoreCase("y") || confirm.equalsIgnoreCase("yes"))) { System.out.format("Received `%s` which is not 'y'/'yes'; not removing secrets.\n", confirm); return; } System.out.format("Removing %d secrets which were deleted before %s from the database\n", affectedCount, deletedBefore.toString()); try { secretDAO.dangerPermanentlyRemoveSecretsDeletedBeforeDate(deletedBefore, sleepMillis); } catch (InterruptedException e) { System.out.println("Error removing secrets; please retry command"); e.printStackTrace(); } }

Target:
@Override public void run(Bootstrap<KeywhizConfig> bootstrap, Namespace namespace, KeywhizConfig config) { String deletedBeforeStr = namespace.getString(INPUT_DELETED_BEFORE); DateTime deletedBefore = getDateIfValid(deletedBeforeStr); if (deletedBefore == null) { return; } Integer sleepMillis = namespace.getInt(INPUT_SLEEP_MILLIS); if (sleepMillis < 0) { System.out.format("Milliseconds to sleep must be nonnegative; got %d\n", sleepMillis); return; } long totalDeletedCount = secretDAO.countDeletedSecrets(); long affectedCount = secretDAO.countSecretsDeletedBeforeDate(deletedBefore); if (affectedCount == 0) { System.out.format( "No secrets deleted before %s were found (out of %d deleted secrets); not altering the database.\n", deletedBefore.toString(), totalDeletedCount); return; } System.out.format( "WARNING: This will PERMANENTLY remove all secrets deleted before %s. " + "%d secrets will be removed, out of %d deleted secrets. Confirm? (y/n)\n", deletedBefore.toString(), affectedCount, totalDeletedCount); String confirm; if (System.console() != null) { Console console = System.console(); confirm = console.readLine(); } else { Scanner scanner = new Scanner(System.in); confirm = scanner.nextLine(); } if (confirm == null || !(confirm.equalsIgnoreCase("y") || confirm.equalsIgnoreCase("yes"))) { System.out.format("Received `%s` which is not 'y'/'yes'; not removing secrets.\n", confirm); return; } System.out.format("Removing %d secrets which were deleted before %s from the database\n", affectedCount, deletedBefore.toString()); try { secretDAO.dangerPermanentlyRemoveSecretsDeletedBeforeDate(deletedBefore, sleepMillis); } catch (InterruptedException e) { System.out.println("Error removing secrets; please retry command"); e.printStackTrace(); } }