guru.bitman.fictionalvieira.bash.BashScript Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
The idea behind Fictional Vieira is to combine Bash and Java strengths to
ease glue logic maintenance usually created using a mix of Bash and CLI
programs
The newest version!
package guru.bitman.fictionalvieira.bash;
import java.util.LinkedList;
import java.util.List;
public class BashScript
{
private static final String NEW_LINE = "\n";
private List commands = new LinkedList<>();
public BashScript() {
commands.add(new BashHeader());
}
public BashScript addCommand(BashCommand command)
{
this.commands.add(command);
return this;
}
public String buildScript()
{
String code = "";
for(BashCommand bCmd : commands) {
// ToDo agregar formateo de código (mejor legibilidad)
code += bCmd.getCode() + NEW_LINE;
}
return code;
}
private class BashHeader
implements BashCommand
{
@Override
public String getCode()
{
return "#!/bin/bash\n";
}
}
}