All Downloads are FREE. Search and download functionalities are using the official Maven repository.

guru.bitman.fictionalvieira.bash.BashScript Maven / Gradle / Ivy

Go to download

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";
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy