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

org.bitbucket.bradleysmithllc.etlunit.cli.ReportCmd Maven / Gradle / Ivy

There is a newer version: 4.1.3
Show newest version
package org.bitbucket.bradleysmithllc.etlunit.cli;

import org.clamshellcli.api.Command;
import org.clamshellcli.api.Configurator;
import org.clamshellcli.api.Context;
import org.clamshellcli.api.IOConsole;
import org.bitbucket.bradleysmithllc.etlunit.maven.ETLUnitMojo;

import java.awt.*;
import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class ReportCmd implements Command
{
	private static final String NAMESPACE = "syscmd";
	public static final String ACTION_NAME = "report";

	public Object execute(Context ctx)
	{
		IOConsole console = ctx.getIoConsole();

		try
		{
			File basedir = new File(".");

			File src = ETLUnitMojo.getReportsDirectoryRoot(basedir);

			File reportIndex = new File(src, "html-reports/index.html").getCanonicalFile();

			if (reportIndex.exists())
			{
				if (Desktop.isDesktopSupported())
				{
					Desktop dt = Desktop.getDesktop();

					dt.browse(reportIndex.toURI());
				}
				else
				{
					console.writeOutput("Your platform does not support the Java Desktop - don't ask me why.\n");
				}
			}
			else
			{
				console.writeOutput("No report file found\n");
			}
		}
		catch (Exception exc)
		{
			exc.printStackTrace();
			console.writeOutput(exc.toString() + Configurator.VALUE_LINE_SEP);
		}

		return null;
	}

	public void plug(Context plug)
	{
		// no load-time setup needed
	}

	public Descriptor getDescriptor()
	{
		return new Descriptor()
		{
			public String getNamespace()
			{
				return NAMESPACE;
			}

			public String getName()
			{
				return ACTION_NAME;
			}

			public String getDescription()
			{
				return "Opens the test report for the last run";
			}

			public String getUsage()
			{
				return "report";
			}

			public Map getArguments()
			{
				Map map = new HashMap();
				return map;
			}
		};
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy