package ahlers.phantom.embedded;

import ahlers.phantom.embedded.parameters.DebugParameter;
import ahlers.phantom.embedded.parameters.IParameter;
import ahlers.phantom.embedded.parameters.ScriptParameter;
import com.google.common.collect.ImmutableList;
import de.flapdoodle.embed.process.extract.IExtractedFileSet;

import java.util.List;

/**
 * @author [[mailto:michael@ahlers.consulting Michael Ahlers]]
 */
public enum PhantomCommandFormatter
        implements IPhantomCommandFormatter {

    INSTANCE;

    public static PhantomCommandFormatter getInstance() {
        return INSTANCE;
    }

    private final ImmutableList<IParameter> arguments = ImmutableList.<IParameter>of(
            DebugParameter.getInstance(),
            ScriptParameter.getInstance()
    );

    @Override
    public ImmutableList<String> format(final IExtractedFileSet files, final IPhantomProcessConfig processConfig) {
        return format(arguments, files, processConfig);
    }

    static ImmutableList<String> format(
            final List<IParameter> arguments,
            final IExtractedFileSet files,
            final IPhantomProcessConfig processConfig
    ) {
        final ImmutableList.Builder<String> builder = ImmutableList.builder();

        builder.add(files.executable().getAbsolutePath());

        for (final IParameter argument : arguments) {
            builder.addAll(argument.format(processConfig));
        }

        return builder.build();
    }

}

@@ -73,135 +73,9 @@
 ers.
-DebugParameter;%0Aimport ahlers.phantom.embedded.parameters.IParameter;%0Aimport ahlers.phantom.embedded.parameters.ScriptParameter
+*
 ;%0Aim
@@ -552,16 +552,16 @@
 ter%3Eof(%0A
-
         
@@ -594,16 +594,744 @@
 ance(),%0A
+            DiskCacheParameter.getInstance(),%0A            DiskCachePathParameter.getInstance(),%0A            IgnoreSSLErrorsParameter.getInstance(),%0A            LoadImagesParameter.getInstance(),%0A            LocalStoragePathParameter.getInstance(),%0A            LocalStorageQuotaParameter.getInstance(),%0A            LocalToRemoteURLAccessParameter.getInstance(),%0A            LocalURLAccessParameter.getInstance(),%0A            MaximumDiskCacheSizeParameter.getInstance(),%0A            OfflineStoragePathParameter.getInstance(),%0A            OfflineStorageQuotaParameter.getInstance(),%0A            OutputEncodingParameter.getInstance(),%0A            ProxyParameter.getInstance(),%0A            RemoteDebuggerPortParameter.getInstance(),%0A
         

Build the kitchen sink (for #3)