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

cli.At Maven / Gradle / Ivy

The newest version!
package cli;

import static java.nio.file.Files.readAllBytes;
import static java.nio.file.Paths.get;
import static org.bitbucket.gkutiel.at.Render.render;
import java.io.IOException;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;

public class At {
	static class In {
		@Parameter(names = "-t", description = "the template file", required = true) String templateFile;
		@Parameter(names = "-d", description = "the data file (json object)", required = true) String dataFile;
	}

	private static String read(final String file) {
		try {
			return new String(readAllBytes(get(file)));
		} catch (final IOException e) {
			throw new RuntimeException(e);
		}
	}

	public static void main(final String[] args) {
		final In in = new In();
		final JCommander jc = new JCommander(in);
		try {
			jc.parse(args);
			final String res = render(read(in.templateFile), read(in.dataFile));
			System.out.println(res);
		} catch (final Exception e) {
			jc.usage();
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy