package org.javaan;

import java.io.IOException;
import java.io.PrintStream;
import java.util.List;

import org.apache.commons.cli.CommandLine;
import org.javaan.model.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class BaseCommand implements Command {
	
	private final static Logger LOG = LoggerFactory.getLogger(BaseCommand.class);

	private static final String HELP_COMMAND_LINE = "javaan %s <files> <options>";

	public BaseCommand() {
		super();
	}

	@Override
	public String getHelpCommandLine() {
		return String.format(HELP_COMMAND_LINE, getName());
	}

	@Override
	public ReturnCodes execute(CommandLine commandLine, String[] files) {
		LOG.info("Processing jar files...");
		JarFileLoader loader = new JarFileLoader();
		try {
			List<Type> types = loader.loadJavaClasses(files);
			LOG.info("Loaded {} class files", types.size());
			execute(commandLine, System.out, types);
		} catch (IOException e) {
			System.out.println(String.format("Could not load class files from libraries: %s", e.getMessage()));
			return ReturnCodes.errorCommand;
		}
		return ReturnCodes.ok;
	}
	
	protected abstract void execute(CommandLine commandLine, PrintStream output, List<Type> types);

}
@@ -948,40 +948,17 @@
 %0A%09%09%09
-System.out.println(String.format
+LOG.error
 (%22Co
@@ -1000,30 +1000,12 @@
 ries
-: %25s%22, e.getMessage())
+%22, e
 );%0A%09

Use error log instead of sys out