3 import java.io.BufferedReader;
4 import java.io.IOException;
5 import java.io.InputStreamReader;
7 import org.eclipse.core.runtime.IProgressMonitor;
8 import org.eclipse.core.runtime.NullProgressMonitor;
9 import org.eclipse.equinox.app.IApplication;
10 import org.eclipse.equinox.app.IApplicationContext;
11 import org.simantics.application.arguments.Arguments;
12 import org.simantics.application.arguments.IArgumentFactory;
13 import org.simantics.application.arguments.IArguments;
14 import org.simantics.application.arguments.SimanticsArguments;
15 import org.simantics.scl.compiler.commands.CommandSession;
16 import org.simantics.scl.osgi.SCLOsgi;
17 import org.simantics.scl.runtime.reporting.SCLReportingHandler;
19 public class SCLScriptRunnerApplication implements IApplication {
22 public Object start(IApplicationContext context) throws Exception {
24 String[] args = (String[])context.getArguments().get("application.args");
25 IProgressMonitor progress = new NullProgressMonitor();
26 Simantics.startUpHeadless(parseArguments(args), progress);
28 Simantics.shutdown(progress);
29 return IApplication.EXIT_OK;
30 } catch(Throwable t) {
38 private void runSCLFromStdin() throws Exception {
39 BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
40 CommandSession commandSession = new CommandSession(SCLOsgi.MODULE_REPOSITORY,
41 SCLReportingHandler.DEFAULT_WITHOUT_ECHO);
44 String line = input.readLine();
49 commandSession.execute(line);
51 } catch(IOException e) {
56 private IArguments parseArguments(String[] args) {
57 IArgumentFactory<?>[] accepted = {
58 SimanticsArguments.RECOVERY_POLICY_FIX_ERRORS,
59 SimanticsArguments.ONTOLOGY_RECOVERY_POLICY_REINSTALL,
60 SimanticsArguments.SERVER,
61 SimanticsArguments.LOCAL_SERVER_PORT,
62 SimanticsArguments.DISABLE_INDEX,
63 SimanticsArguments.DATABASE_ID,
65 IArguments result = Arguments.parse(args, accepted);