public String render(OsFamily family) { StringBuilder switchClause = new StringBuilder(); addArgValidation(switchClause, family); switchClause.append(Utils.replaceTokens(OS_TO_SWITCH_PATTERN.get(family), ImmutableMap.of("arg", arg + ""))); for (Entry<String, Statement> entry : valueToActions.entrySet()) { StringBuilder actionBuilder = new StringBuilder(); boolean shouldIndent = true; boolean inRunScript = false; boolean inCreateFile = false; for (String line : Splitter.on(ShellToken.LF.to(family)).split(entry.getValue().render(family))) { if (shouldIndent) actionBuilder.append(INDENT); actionBuilder.append(line).append(ShellToken.LF.to(family)); if (line.indexOf(CreateRunScript.DELIMITER) != -1) { inRunScript = inRunScript ? false : true; } if (line.indexOf(AppendFile.DELIMITER) != -1) { inCreateFile = inCreateFile ? false : true; } shouldIndent = !inCreateFile && !inRunScript; } actionBuilder.delete(actionBuilder.lastIndexOf(ShellToken.LF.to(family)), actionBuilder.length()); switchClause.append(Utils.replaceTokens(OS_TO_CASE_PATTERN.get(family), ImmutableMap.of("value", entry .getKey(), "action", actionBuilder.toString()))); } switchClause.append(OS_TO_END_SWITCH_PATTERN.get(family)); return switchClause.toString(); }
public String render(OsFamily family) { StringBuilder switchClause = new StringBuilder(); addArgValidation(switchClause, family); switchClause.append(Utils.replaceTokens(OS_TO_SWITCH_PATTERN.get(family), ImmutableMap.of("arg", arg + ""))); for (Entry<String, Statement> entry : valueToActions.entrySet()) { StringBuilder actionBuilder = new StringBuilder(); boolean shouldIndent = true; boolean inRunScript = false; boolean inCreateFile = false; for (String line : Splitter.on(ShellToken.LF.to(family)).split(entry.getValue().render(family))) { if (shouldIndent) actionBuilder.append(INDENT); actionBuilder.append(line).append(ShellToken.LF.to(family)); if (line.indexOf(CreateRunScript.DELIMITER) != -1) { inRunScript = inRunScript ? false : true; } if (line.indexOf(AppendFile.DELIMITER) != -1) { inCreateFile = inCreateFile ? false : true; } shouldIndent = !inCreateFile && !inRunScript; } actionBuilder.delete(actionBuilder.lastIndexOf(ShellToken.LF.to(family)), actionBuilder.length()); switchClause.append(Utils.replaceTokens(OS_TO_CASE_PATTERN.get(family), ImmutableMap.of("value", entry .getKey(), "action", actionBuilder.toString()))); } switchClause.append(OS_TO_END_SWITCH_PATTERN.get(family)); return switchClause.toString(); }
public String render(OsFamily family) { StringBuilder switchClause = new StringBuilder(); addArgValidation(switchClause, family); switchClause.append(Utils.replaceTokens(OS_TO_SWITCH_PATTERN.get(family), ImmutableMap.of("arg", arg + ""))); for (Entry<String, Statement> entry : valueToActions.entrySet()) { StringBuilder actionBuilder = new StringBuilder(); boolean shouldIndent = true; boolean inRunScript = false; boolean inCreateFile = false; for (String line : Splitter.on(ShellToken.LF.to(family)).split(entry.getValue().render(family))) { if (shouldIndent) actionBuilder.append(INDENT); actionBuilder.append(line).append(ShellToken.LF.to(family)); if (line.indexOf(CreateRunScript.DELIMITER) != -1) { inRunScript = inRunScript ? false : true; } if (line.indexOf(AppendFile.DELIMITER) != -1) { inCreateFile = inCreateFile ? false : true; } shouldIndent = !inCreateFile && !inRunScript; } actionBuilder.delete(actionBuilder.lastIndexOf(ShellToken.LF.to(family)), actionBuilder.length()); switchClause.append(Utils.replaceTokens(OS_TO_CASE_PATTERN.get(family), ImmutableMap.of("value", entry .getKey(), "action", actionBuilder.toString()))); } switchClause.append(OS_TO_END_SWITCH_PATTERN.get(family)); return switchClause.toString(); }
public String render(OsFamily family) { StringBuilder switchClause = new StringBuilder(); addArgValidation(switchClause, family); switchClause.append(Utils.replaceTokens(OS_TO_SWITCH_PATTERN.get(family), ImmutableMap.of("arg", arg + ""))); for (Entry<String, Statement> entry : valueToActions.entrySet()) { StringBuilder actionBuilder = new StringBuilder(); boolean shouldIndent = true; boolean inRunScript = false; boolean inCreateFile = false; for (String line : Splitter.on(ShellToken.LF.to(family)).split(entry.getValue().render(family))) { if (shouldIndent) actionBuilder.append(INDENT); actionBuilder.append(line).append(ShellToken.LF.to(family)); if (line.indexOf(CreateRunScript.DELIMITER) != -1) { inRunScript = inRunScript ? false : true; } if (line.indexOf(AppendFile.DELIMITER) != -1) { inCreateFile = inCreateFile ? false : true; } shouldIndent = !inCreateFile && !inRunScript; } actionBuilder.delete(actionBuilder.lastIndexOf(ShellToken.LF.to(family)), actionBuilder.length()); switchClause.append(Utils.replaceTokens(OS_TO_CASE_PATTERN.get(family), ImmutableMap.of("value", entry .getKey(), "action", actionBuilder.toString()))); } switchClause.append(OS_TO_END_SWITCH_PATTERN.get(family)); return switchClause.toString(); }
public String render(OsFamily family) { StringBuilder switchClause = new StringBuilder(); addArgValidation(switchClause, family); switchClause.append(Utils.replaceTokens(OS_TO_SWITCH_PATTERN.get(family), ImmutableMap.of("arg", arg + ""))); for (Entry<String, Statement> entry : valueToActions.entrySet()) { StringBuilder actionBuilder = new StringBuilder(); boolean shouldIndent = true; boolean inRunScript = false; boolean inCreateFile = false; for (String line : Splitter.on(ShellToken.LF.to(family)).split(entry.getValue().render(family))) { if (shouldIndent) actionBuilder.append(INDENT); actionBuilder.append(line).append(ShellToken.LF.to(family)); if (line.indexOf(CreateRunScript.DELIMITER) != -1) { inRunScript = inRunScript ? false : true; } if (line.indexOf(AppendFile.DELIMITER) != -1) { inCreateFile = inCreateFile ? false : true; } shouldIndent = !inCreateFile && !inRunScript; } actionBuilder.delete(actionBuilder.lastIndexOf(ShellToken.LF.to(family)), actionBuilder.length()); switchClause.append(Utils.replaceTokens(OS_TO_CASE_PATTERN.get(family), ImmutableMap.of("value", entry .getKey(), "action", actionBuilder.toString()))); } switchClause.append(OS_TO_END_SWITCH_PATTERN.get(family)); return switchClause.toString(); }
public String render(OsFamily family) { StringBuilder switchClause = new StringBuilder(); addArgValidation(switchClause, family); switchClause.append(Utils.replaceTokens(OS_TO_SWITCH_PATTERN.get(family), ImmutableMap.of("arg", arg + ""))); for (Entry<String, Statement> entry : valueToActions.entrySet()) { StringBuilder actionBuilder = new StringBuilder(); boolean shouldIndent = true; boolean inRunScript = false; boolean inCreateFile = false; for (String line : Splitter.on(ShellToken.LF.to(family)).split(entry.getValue().render(family))) { if (shouldIndent) actionBuilder.append(INDENT); actionBuilder.append(line).append(ShellToken.LF.to(family)); if (line.indexOf(CreateRunScript.DELIMITER) != -1) { inRunScript = inRunScript ? false : true; } if (line.indexOf(AppendFile.DELIMITER) != -1) { inCreateFile = inCreateFile ? false : true; } shouldIndent = !inCreateFile && !inRunScript; } actionBuilder.delete(actionBuilder.lastIndexOf(ShellToken.LF.to(family)), actionBuilder.length()); switchClause.append(Utils.replaceTokens(OS_TO_CASE_PATTERN.get(family), ImmutableMap.of("value", entry .getKey(), "action", actionBuilder.toString()))); } switchClause.append(OS_TO_END_SWITCH_PATTERN.get(family)); return switchClause.toString(); }