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

org.etlunit.cli.OpenCmd Maven / Gradle / Ivy

There is a newer version: 1.6.9
Show newest version
package org.etlunit.cli;

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

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

public class OpenCmd implements Command
{
	private static final String NAMESPACE = "syscmd";
	public static final String ACTION_NAME = "open";

	public Object execute(Context ctx)
	{
		IOConsole console = ctx.getIoConsole();
		String [] inputLine = (String []) ctx.getValue(Context.KEY_COMMAND_LINE_ARGS);

		try
		{
			File basedir = new File((inputLine == null || inputLine.length == 0) ? "." : inputLine[0]).getCanonicalFile();

			if (Desktop.isDesktopSupported())
			{
				Desktop dt = Desktop.getDesktop();
				dt.open(basedir);
			}
			else
			{
				console.writeOutput("Your platform does not support the Java Desktop - don't ask me why.\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 project directory in a file window";
			}

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

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

				map.put("path", "Optional file path.");

				return map;
			}
		};
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy