<commit_before>package com.liferay.blade.cli;

import aQute.lib.getopt.Arguments;
import aQute.lib.getopt.Description;
import aQute.lib.getopt.Options;

import com.liferay.blade.cli.jmx.IDEConnector;

import java.io.File;

import java.util.Collections;
import java.util.Formatter;
import java.util.List;

/**
 * @author <NAME>
 */
public class OpenCommand {

	public OpenCommand(blade blade, OpenOptions options) throws Exception {
		_blade = blade;
		_options = options;
	}

	public void execute() throws Exception {
		List<String> args = _options._arguments();

		if (args.size() == 0) {

			// Default command

			printHelp();
		}
		else {
			doExecute();
		}
	}

	@Arguments(arg = "file or directory to open/import")
	@Description("Opens or imports a file or directory in Liferay IDE")
	public interface OpenOptions extends Options {

		@Description("The workspace to open or import this file or project")
		public String workspace();

	}

	private void addError(String prefix, String msg) {
		_blade.addErrors(prefix, Collections.singleton(msg));
	}

	private void doExecute() throws Exception {
		File fileName = new File(_options._arguments().get(0));

		if (!fileName.exists()) {
			addError(
				"open",
				"Unable to find specified file " + fileName.getAbsolutePath());
			return;
		}

		IDEConnector connector = null;

		try {
			connector = new IDEConnector();
		}
		catch (Exception e) {

			// ignore

		}

		if (connector == null) {
			addError(
				"open", "Unable to connect to Eclipse/Liferay IDE instance.");
			return;
		}

		if (fileName.isDirectory()) {
			Object retval = connector.openDir(fileName);

			if (retval != null) {
				addError("open", retval.toString());
				return;
			}
		}
	}

	private void printHelp() throws Exception {
		Formatter f = new Formatter();
		_options._command().help(f, this);
		_blade.out().println(f);
		f.close();
	}

	private final blade _blade;
	private final OpenOptions _options;

}<commit_msg>removed because this code can never be reached<commit_after>package com.liferay.blade.cli;

import aQute.lib.getopt.Arguments;
import aQute.lib.getopt.Description;
import aQute.lib.getopt.Options;

import com.liferay.blade.cli.jmx.IDEConnector;

import java.io.File;

import java.util.Collections;

/**
 * @author <NAME>
 */
public class OpenCommand {

	public OpenCommand(blade blade, OpenOptions options) throws Exception {
		_blade = blade;
		_options = options;
	}

	public void execute() throws Exception {
		doExecute();
	}

	@Arguments(arg = "file or directory to open/import")
	@Description("Opens or imports a file or directory in Liferay IDE")
	public interface OpenOptions extends Options {

		@Description("The workspace to open or import this file or project")
		public String workspace();

	}

	private void addError(String prefix, String msg) {
		_blade.addErrors(prefix, Collections.singleton(msg));
	}

	private void doExecute() throws Exception {
		File fileName = new File(_options._arguments().get(0));

		if (!fileName.exists()) {
			addError(
				"open",
				"Unable to find specified file " + fileName.getAbsolutePath());
			return;
		}

		IDEConnector connector = null;

		try {
			connector = new IDEConnector();
		}
		catch (Exception e) {

			// ignore

		}

		if (connector == null) {
			addError(
				"open", "Unable to connect to Eclipse/Liferay IDE instance.");
			return;
		}

		if (fileName.isDirectory()) {
			Object retval = connector.openDir(fileName);

			if (retval != null) {
				addError("open", retval.toString());
				return;
			}
		}
	}

	private final blade _blade;
	private final OpenOptions _options;

	private final blade _blade;
	private final OpenOptions _options;

}
{'fraction_non_alphanumeric': 0.1187363834422658, 'fraction_numerical': 0.0008169934640522876, 'mean_word_length': 3.7454780361757107, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '137786', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1145, 'n_words': 324}