1 package org.simantics.scl.db;
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.Simantics;
12 import org.simantics.application.arguments.Arguments;
13 import org.simantics.application.arguments.IArgumentFactory;
14 import org.simantics.application.arguments.IArguments;
15 import org.simantics.application.arguments.SimanticsArguments;
16 import org.simantics.scl.compiler.commands.CommandSession;
17 import org.simantics.scl.osgi.SCLOsgi;
18 import org.simantics.scl.runtime.reporting.SCLReportingHandler;
20 public class SCLScriptRunnerApplication implements IApplication {
23 public Object start(IApplicationContext context) throws Exception {
25 String[] args = (String[])context.getArguments().get("application.args");
26 IProgressMonitor progress = new NullProgressMonitor();
27 Simantics.startUpHeadless(parseArguments(args), progress);
29 Simantics.shutdown(progress);
30 return IApplication.EXIT_OK;
31 } catch(Throwable t) {
39 private void runSCLFromStdin() throws Exception {
40 BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
41 CommandSession commandSession = new CommandSession(SCLOsgi.MODULE_REPOSITORY,
42 SCLReportingHandler.DEFAULT_WITHOUT_ECHO);
45 String line = input.readLine();
50 commandSession.execute(line);
52 } catch(IOException e) {
57 private IArguments parseArguments(String[] args) {
58 IArgumentFactory<?>[] accepted = {
59 SimanticsArguments.RECOVERY_POLICY_FIX_ERRORS,
60 SimanticsArguments.ONTOLOGY_RECOVERY_POLICY_REINSTALL,
61 SimanticsArguments.SERVER,
62 SimanticsArguments.LOCAL_SERVER_PORT,
63 SimanticsArguments.DISABLE_INDEX,
64 SimanticsArguments.DATABASE_ID,
66 IArguments result = Arguments.parse(args, accepted);