/** * interprets and adds a newline to the statement */ public static Statement exec(String portableStatement) { return interpret(portableStatement + "{lf}"); }
/** * interprets and adds a newline to the statement */ public static Statement exec(String portableStatement) { return interpret(portableStatement + "{lf}"); }
/** * * * @param method * http method: ex GET * @param endpoint * uri corresponding to the request * @param headers * request headers to send */ public PipeHttpResponseToBash(String method, URI endpoint, Multimap<String, String> headers) { super(Statements.interpret("bash"), method, endpoint, headers); }
/** * interprets and adds a newline to the statement */ public static Statement exec(String portableStatement) { return interpret(portableStatement + "{lf}"); }
/** * interprets and adds a newline to the statement */ public static Statement exec(String portableStatement) { return interpret(portableStatement + "{lf}"); }
/** * interprets and adds a newline to the statement */ public static Statement exec(String portableStatement) { return interpret(portableStatement + "{lf}"); }
/** * * * @param method * http method: ex GET * @param endpoint * uri corresponding to the request * @param headers * request headers to send */ public PipeHttpResponseToBash(String method, URI endpoint, Multimap<String, String> headers) { super(Statements.interpret("bash"), method, endpoint, headers); }
/** * interprets and adds a newline to the statement */ public static Statement exec(String portableStatement) { return interpret(portableStatement + "{lf}"); }
/** * * * @param method * http method: ex GET * @param endpoint * uri corresponding to the request * @param headers * request headers to send */ public PipeHttpResponseToBash(String method, URI endpoint, Multimap<String, String> headers) { super(Statements.interpret("bash"), method, endpoint, headers); }
public static Statement addAuthorizedKeysToRoot(String publicKey) { return newStatementList( appendFile("/root/.ssh/authorized_keys", Splitter.on('\n').split(publicKey)), interpret("chmod 600 /root/.ssh/authorized_keys")); }
@Test public void testSwitchOn() { ScriptBuilder builder = new ScriptBuilder(); builder.addStatement(switchArg(1, ImmutableMap.of("start", interpret("echo started{lf}"), "stop", interpret("echo stopped{lf}")))); assertEquals(builder.statements, ImmutableList.of(new SwitchArg(1, ImmutableMap.of("start", interpret("echo started{lf}"), "stop", interpret("echo stopped{lf}"))))); }
public void testSwitchArgWindows() { assertEquals( new SwitchArg(1, ImmutableMap.of("0", interpret("echo hello zero{lf}"), "1", interpret("echo hello one{lf}"))).render(OsFamily.WINDOWS), "if not \"%1\" == \"0\" if not \"%1\" == \"1\" (\r\n set EXCEPTION=bad argument: %1 not in 0 1\r\n goto abort\r\n)\r\ngoto CASE_%1\r\n:CASE_0\r\n echo hello zero\r\n GOTO END_SWITCH\r\n:CASE_1\r\n echo hello one\r\n GOTO END_SWITCH\r\n:END_SWITCH\r\n"); } }
public void testSwitchArgWindows() { assertEquals( new SwitchArg(1, ImmutableMap.of("0", interpret("echo hello zero{lf}"), "1", interpret("echo hello one{lf}"))).render(OsFamily.WINDOWS), "if not \"%1\" == \"0\" if not \"%1\" == \"1\" (\r\n set EXCEPTION=bad argument: %1 not in 0 1\r\n goto abort\r\n)\r\ngoto CASE_%1\r\n:CASE_0\r\n echo hello zero\r\n GOTO END_SWITCH\r\n:CASE_1\r\n echo hello one\r\n GOTO END_SWITCH\r\n:END_SWITCH\r\n"); } }
@Test public void testSwitchOn() { ScriptBuilder builder = new ScriptBuilder(); builder.addStatement(switchArg(1, ImmutableMap.of("start", interpret("echo started{lf}"), "stop", interpret("echo stopped{lf}")))); assertEquals(builder.statements, ImmutableList.of(new SwitchArg(1, ImmutableMap.of("start", interpret("echo started{lf}"), "stop", interpret("echo stopped{lf}"))))); }