// Path: matrix-cli/src/main/java/com/artemis/cli/converter/FileOutputConverter.java
// public class FileOutputConverter implements IStringConverter<File> {
// 
// 	@Override
// 	public File convert(String value) {
// 		File file = new File(value);
// 		if (file.isDirectory())
// 			file = new File(file, "matrix.html");
// 		
// 		return file;
// 	}
// 
// }
// 
// Path: matrix-cli/src/main/java/com/artemis/cli/converter/FolderConverter.java
// public class FolderConverter implements IStringConverter<File> {
// 
// 	@Override
// 	public File convert(String value) {
// 		File folder = new File(value);
// 		if (!folder.isDirectory())
// 			throw new RuntimeException(value + " is not a folder.");
// 		return folder;
// 	}
// 
// }
// 
// Path: matrix/src/main/java/net/onedaybeard/ecs/model/ComponentDependencyMatrix.java
// public class ComponentDependencyMatrix implements Opcodes  {
// 	private final List<URI> files;
// 	private final File output;
// 	private final String projectName;
// 
// 	public ComponentDependencyMatrix(String projectName, List<URI> files, File output) {
// 		this.projectName = projectName;
// 		this.files = files;
// 		this.output = output;
// 	}
// 	
// 	public String detectAndProcess() {
// 		EcsTypeInspector typeInspector;
// 
// 		// TODO: get classpath and/or deps
// 		for (String ecs : asList("artemis", "ashley")) {
// 			typeInspector = new EcsTypeInspector(files, "/" + ecs);
// 			if (typeInspector.foundEcsClasses()) {
// 				process(typeInspector);
// 				return "Found ECS framework: " + ecs;
// 			}
// 		}
// 
// 		return "Failed finding any ECS related classes.";
// 	}
// 
// 	public void process() {
// 		process("");
// 	}
// 
// 	public void process(String resourcePrefix) {
// 		process(new EcsTypeInspector(files, resourcePrefix));
// 	}
// 
// 	private void process(EcsTypeInspector typeInspector) {
// 		write(typeInspector.getTypeMap(), typeInspector.getMatrixData());
// 	}
// 
// 	private void write(SortedMap<String, List<RowTypeMapping>> mappedSystems, MatrixData matrix) {
// 		Theme theme = new Theme();
// 		Chunk chunk = theme.makeChunk("matrix");
// 		
// 		List<RowTypeMapping> rows = new ArrayList<RowTypeMapping>();
// 		for (Entry<String,List<RowTypeMapping>> entry : mappedSystems.entrySet()) {
// 			rows.add(new RowTypeMapping(entry.getKey()));
// 			rows.addAll(entry.getValue());
// 		}
// 		
// 		chunk.set("longestName", MatrixStringUtil.findLongestClassName(mappedSystems).replaceAll(".", "_") + "______");
// 		
// 		chunk.set("rows", rows);
// 
// 		chunk.set("headersComponents", matrix.componentColumns);
// 		chunk.set("componentCount", matrix.componentColumns.size());
// 
// 		chunk.set("headersManagers", matrix.managerColumns);
// 		chunk.set("managerCount", matrix.managerColumns.size());
// 
// 		chunk.set("headersSystems", matrix.systemColumns);
// 		chunk.set("systemCount", matrix.systemColumns.size());
// 
// 		chunk.set("factoryCount", matrix.factoryColumns.size());
// 		chunk.set("headersFactories", matrix.factoryColumns);
// 
// 		chunk.set("project", projectName);
// 		
// 		BufferedWriter out = null;
// 		try {
// 			out = new BufferedWriter(new FileWriter(output));
// 			chunk.render(out);
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		} finally {
// 			if (out != null) try {
// 				out.close();
// 			} catch (IOException e) {
// 				throw new RuntimeException(e);
// 			}
// 		}
// 	}
// }


import java.io.File;
import java.util.Arrays;
import com.artemis.cli.converter.FileOutputConverter;
import com.artemis.cli.converter.FolderConverter;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import net.onedaybeard.ecs.model.ComponentDependencyMatrix;
package com.artemis.cli;



@Parameters(
		commandDescription="Generate the Component Dependency Matrix from existing classes")
public class MatrixCommand {
	static final String COMMAND = "matrix";

	@Parameter(
		names = {"-h", "--help"},
		description= "Displays this help message.",
		help = true)
	boolean help;

	@Parameter(
		names = {"-l", "--label"},
		description = "Project name, used as page title",
		required = false)
	private String projectName = "Unnamed project";
	
	@Parameter(
		names = {"-c", "--class-folder"},
		description = "Root class folder",
		converter = FolderConverter.class,
		required = true)
	private File classRoot;
	
	@Parameter(
		names = {"-o", "--output"},
		description = "Save to file, destination may be given as a folder path",
// Path: matrix-cli/src/main/java/com/artemis/cli/converter/FileOutputConverter.java
// public class FileOutputConverter implements IStringConverter<File> {
// 
// 	@Override
// 	public File convert(String value) {
// 		File file = new File(value);
// 		if (file.isDirectory())
// 			file = new File(file, "matrix.html");
// 		
// 		return file;
// 	}
// 
// }
// 
// Path: matrix-cli/src/main/java/com/artemis/cli/converter/FolderConverter.java
// public class FolderConverter implements IStringConverter<File> {
// 
// 	@Override
// 	public File convert(String value) {
// 		File folder = new File(value);
// 		if (!folder.isDirectory())
// 			throw new RuntimeException(value + " is not a folder.");
// 		return folder;
// 	}
// 
// }
// 
// Path: matrix/src/main/java/net/onedaybeard/ecs/model/ComponentDependencyMatrix.java
// public class ComponentDependencyMatrix implements Opcodes  {
// 	private final List<URI> files;
// 	private final File output;
// 	private final String projectName;
// 
// 	public ComponentDependencyMatrix(String projectName, List<URI> files, File output) {
// 		this.projectName = projectName;
// 		this.files = files;
// 		this.output = output;
// 	}
// 	
// 	public String detectAndProcess() {
// 		EcsTypeInspector typeInspector;
// 
// 		// TODO: get classpath and/or deps
// 		for (String ecs : asList("artemis", "ashley")) {
// 			typeInspector = new EcsTypeInspector(files, "/" + ecs);
// 			if (typeInspector.foundEcsClasses()) {
// 				process(typeInspector);
// 				return "Found ECS framework: " + ecs;
// 			}
// 		}
// 
// 		return "Failed finding any ECS related classes.";
// 	}
// 
// 	public void process() {
// 		process("");
// 	}
// 
// 	public void process(String resourcePrefix) {
// 		process(new EcsTypeInspector(files, resourcePrefix));
// 	}
// 
// 	private void process(EcsTypeInspector typeInspector) {
// 		write(typeInspector.getTypeMap(), typeInspector.getMatrixData());
// 	}
// 
// 	private void write(SortedMap<String, List<RowTypeMapping>> mappedSystems, MatrixData matrix) {
// 		Theme theme = new Theme();
// 		Chunk chunk = theme.makeChunk("matrix");
// 		
// 		List<RowTypeMapping> rows = new ArrayList<RowTypeMapping>();
// 		for (Entry<String,List<RowTypeMapping>> entry : mappedSystems.entrySet()) {
// 			rows.add(new RowTypeMapping(entry.getKey()));
// 			rows.addAll(entry.getValue());
// 		}
// 		
// 		chunk.set("longestName", MatrixStringUtil.findLongestClassName(mappedSystems).replaceAll(".", "_") + "______");
// 		
// 		chunk.set("rows", rows);
// 
// 		chunk.set("headersComponents", matrix.componentColumns);
// 		chunk.set("componentCount", matrix.componentColumns.size());
// 
// 		chunk.set("headersManagers", matrix.managerColumns);
// 		chunk.set("managerCount", matrix.managerColumns.size());
// 
// 		chunk.set("headersSystems", matrix.systemColumns);
// 		chunk.set("systemCount", matrix.systemColumns.size());
// 
// 		chunk.set("factoryCount", matrix.factoryColumns.size());
// 		chunk.set("headersFactories", matrix.factoryColumns);
// 
// 		chunk.set("project", projectName);
// 		
// 		BufferedWriter out = null;
// 		try {
// 			out = new BufferedWriter(new FileWriter(output));
// 			chunk.render(out);
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		} finally {
// 			if (out != null) try {
// 				out.close();
// 			} catch (IOException e) {
// 				throw new RuntimeException(e);
// 			}
// 		}
// 	}
// }


// Path: matrix-cli/src/main/java/com/artemis/cli/MatrixCommand.java
import java.io.File;
import java.util.Arrays;
import com.artemis.cli.converter.FileOutputConverter;
import com.artemis.cli.converter.FolderConverter;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import net.onedaybeard.ecs.model.ComponentDependencyMatrix;

package com.artemis.cli;



@Parameters(
		commandDescription="Generate the Component Dependency Matrix from existing classes")
public class MatrixCommand {
	static final String COMMAND = "matrix";

	@Parameter(
		names = {"-h", "--help"},
		description= "Displays this help message.",
		help = true)
	boolean help;

	@Parameter(
		names = {"-l", "--label"},
		description = "Project name, used as page title",
		required = false)
	private String projectName = "Unnamed project";
	
	@Parameter(
		names = {"-c", "--class-folder"},
		description = "Root class folder",
		converter = FolderConverter.class,
		required = true)
	private File classRoot;
	
	@Parameter(
		names = {"-o", "--output"},
		description = "Save to file, destination may be given as a folder path",
		converter = FileOutputConverter.class,