class ExecScript implements Script, StreamConsumer {

    public Commandline buildCommandline() throws CruiseControlException {
        Commandline cmdLine = new Commandline();

        // make sure we have a command
        if (execCommand != null) {
            cmdLine.setExecutable(execCommand);
        } else {
            throw new CruiseControlException("no command to be executed");
        }

        // add the arguments if necessary
        if (execArgs != null) {
            cmdLine.addArguments(Commandline.translateCommandline(execArgs));
        }

        // log the command if debug is enabled
        if (LOG.isDebugEnabled()) {
            final StringBuilder sb = new StringBuilder();
            sb.append("Executing Command: ");
            final String[] args = cmdLine.getCommandline();
            for (final String arg : args) {
                sb.append(arg);
                sb.append(" ");
            }
            LOG.debug(sb.toString());
        }
        return cmdLine;
    }

}