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

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

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

import cli.Run;
import org.etlunit.io.FileBuilder;
import org.etlunit.util.IOUtils;
import org.etlunit.util.JSonBuilderProxy;

import java.io.File;

public class CliMain {
	public static File WORKING_ROOT = new File(".");

	public static void main(String [] argv) throws Exception {
		File root = new FileBuilder(WORKING_ROOT).subdir("target").mkdirs().file();
		File lib = new FileBuilder(WORKING_ROOT).subdir("lib").mkdirs().file();

		File file = new FileBuilder(root).subdir("cli").mkdirs().name("cli.config").file();

		JSonBuilderProxy proxy = new JSonBuilderProxy()
			.object()
				.key("properties")
					.object()
						.key("libDir")
						.value(lib.getAbsolutePath())
						.key("pluginsDir")
						.value(lib.getAbsolutePath())
					.endObject()
				.key("controllers")
					.object()
						.key("org.clamshellcli.impl.CmdController")
							.object()
								.key("enabled")
								.value("true")
								.key("inputPattern")
								.value("\\s*(exit|help|sysinfo|" + getCommandsList() + "|last)\\b.*")
								.key("expectedInputs")
									.array()
									.endArray()
							.endObject()
					.endObject()
			.endObject();

		IOUtils.writeBufferToFile(file, new StringBuffer(proxy.toString()));

		System.setProperty("cli.config.file", file.getAbsolutePath());

		Run.main(argv);
	}

	private static String getCommandsList() {
		return
				SleepCmd.ACTION_NAME + "|"
				+ TimeCmd.ACTION_NAME + "|"
				+ ListInstalledFeaturesCmd.ACTION_NAME + "|"
				+ ListAvailableFeaturesCmd.ACTION_NAME + "|"
				+ DescribeCmd.ACTION_NAME + "|"
				+ TestCmd.ACTION_NAME + "|"
				+ AddAvailableFeatureCmd.ACTION_NAME + "|"
				+ SetCmd.ACTION_NAME + "|"
				+ UpdateCmd.ACTION_NAME + "|"
				+ MigrateCmd.ACTION_NAME + "|"
				+ VersionsCmd.ACTION_NAME + "|"
				+ OpenCmd.ACTION_NAME + "|"
				+ ReportCmd.ACTION_NAME;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy