#!/usr/bin/java --source 17 import static java.lang.System.* ; import java.util.*; class diff3 { public static void main(String[] command_line_arguments) throws Throwable { if(command_line_arguments.length != 9) throw fail("svn diff3 was supposed to give us 9 arguments. did the interface change? we got %s arguments.", command_line_arguments.length); //some old gnudiff flag, which meld ignores var ignored_unified_flag = command_line_arguments[0]; if(!ignored_unified_flag.equals("-u")) throw fail("the first argument should be the `-u` flag, which meld will ignore, but was %s.", ignored_unified_flag); var left_label_flag = command_line_arguments[1]; var left_label = command_line_arguments[2]; var right_label_flag = command_line_arguments[3]; var right_label = command_line_arguments[4]; if(!(left_label_flag.equals("-L") && right_label_flag.equals("-L"))) throw fail("flags for the labes should have been `-L`, but were %s and %s.", left_label_flag, right_label_flag); var left_file = command_line_arguments[5]; var right_file = command_line_arguments[6]; out.printf("%s --label '%s' '%s' --label '%s' '%s'%n", emphasize_global("meld"), left_label, left_file, right_label, right_file); throw fail("not yet"); // var code = call("meld","--auto-merge", "--label", left_label, left_file, "--label", right_label, right_file); // throw exit(code); } static int call( String... command) throws Exception { return new ProcessBuilder() .command(command) .inheritIO() .start() .onExit() .join() .exitValue(); } static Throwable exit(int code) { System.exit(code); //abuse control flow to make compiler realize `exit` will never return return new Throwable(); } static String emphasize_global(String message) { return "\033[4m" + message + "\033[0m"; } static String emphasize_local(String message) { return "\033[3m" + message + "\033[0m"; } static Throwable fail(String message, Object... arguments) { out.printf(message, arguments); System.exit(1); //abuse control flow to make compiler realize `exit` will never return return new Throwable(); } static Throwable fail() { System.exit(1); //abuse control flow to make compiler realize `exit` will never return return new Throwable(); } } // vim:ft=java