# HG changeset patch # User wenzelm # Date 1626004081 -7200 # Node ID 5351719ab2a027f8dd56fe338b1153314b00ae36 # Parent f090787bb4c429185381571918283b7adb621578 support for command-line operations; diff -r f090787bb4c4 -r 5351719ab2a0 src/Tools/Setup/isabelle/setup/Setup.java --- a/src/Tools/Setup/isabelle/setup/Setup.java Sun Jul 11 13:46:14 2021 +0200 +++ b/src/Tools/Setup/isabelle/setup/Setup.java Sun Jul 11 13:48:01 2021 +0200 @@ -6,10 +6,65 @@ package isabelle.setup; + +import java.io.IOException; +import java.security.NoSuchAlgorithmException; + + class Setup { + private static void echo(String msg) + { + System.out.println(msg); + + } + private static void fail(String msg) + { + echo(msg); + System.exit(2); + } + + private static void check_args(boolean b) + { + if (!b) { fail("Bad command-line arguments"); } + } + public static void main(String[] args) { - System.out.println("Isabelle setup"); + int n = args.length; + check_args(n > 0); + + String op = args[0]; + try { + switch (op) { + case "build": + check_args(n == 1); + Build.build_components(false); + break; + case "build_fresh": + check_args(n == 1); + Build.build_components(true); + break; + case "classpath": + check_args(n == 1); + echo(Environment.join_standard_paths(Build.classpath())); + break; + case "services": + check_args(n == 1); + for (String s : Build.services()) { echo(s); } + break; + default: + fail("Bad setup operation " + Environment.quote(op)); + break; + } + } + catch (InterruptedException e) { + echo("Interrupt"); + System.exit(139); + } + catch (IOException | RuntimeException | NoSuchAlgorithmException e) { + echo(e.getMessage()); + System.exit(1); + } } }