public void execute( String script ) { groovy.execute( script ); } }
@Override public Object eval(final String script) throws ScriptException { return this.shell.execute(script); }
public void runScripts(List<File> files) { final Groovysh shell = createShell(); try { for (File file : files) { if (!file.exists() || !file.canRead() || !file.isFile()) { throw new GroovyShellException("Unable to open script file: " + file); } shell.execute(":load " + file.getAbsolutePath()); } } catch (Exception e) { throw new GroovyShellException(e); } }
public void runScripts(List<File> files) { final Groovysh shell = createShell(); try { for (File file : files) { if (!file.exists() || !file.canRead() || !file.isFile()) { throw new GroovyShellException("Unable to open script file: " + file); } shell.execute(":load " + file.getAbsolutePath()); } } catch (Exception e) { throw new GroovyShellException(e); } }
public static void main( String... args ) throws IOException { PropertyConfigurator.configure( System.getProperty( "log4j.configuration" ) ); if( args.length > 0 ) { GroovyMain.main( args ); } else { Groovysh shell = new Groovysh(); for( String name : IMPORTS ) { shell.execute( "import " + name ); } shell.run( null ); } }
protected AdminHelpCommand(Groovysh shell) { super(shell, "adminhelp", "\\ah"); //$NON-NLS-1$ //$NON-NLS-2$ //hook to introduce default imports final String[] imports = GroovyAdminConsole.IMPORTS.split("\n"); //$NON-NLS-1$ for(String aimport : imports){ shell.execute(aimport); } //for backwards compatibility add aliases to 1.7 Groovy commands for (Command cmd :new ArrayList<Command>(shell.getRegistry().commands())) { if (cmd.getHidden()) { continue; } String name = cmd.getName(); if (name.startsWith(":")) { //$NON-NLS-1$ shell.execute(":alias " + name.substring(1) + " " + name); //$NON-NLS-1$ //$NON-NLS-2$ String shortCut = cmd.getShortcut(); if (shortCut.startsWith(":")) { //$NON-NLS-1$ shell.execute(":alias \\" + shortCut.substring(1) + " " + name); //$NON-NLS-1$ //$NON-NLS-2$ } } } }
public static void main( String... args ) throws IOException { PropertyConfigurator.configure( System.getProperty( "log4j.configuration" ) ); if( args.length > 0 ) { GroovyMain.main( args ); } else { Groovysh shell = new Groovysh(); for( String name : IMPORTS ) { shell.execute( "import " + name ); } shell.run( null ); } }
System.out.println(" cypher - run a cypher query (usage: cypher(\"\"\"MATCH (n) RETURN n LIMIT 10\"\"\"))"); try { shell.execute("import " + Visibility.class.getPackage().getName() + ".*;"); shell.execute("import " + GeoPoint.class.getPackage().getName() + ".*;"); shell.execute("import " + GeoCompare.class.getPackage().getName() + ".*;"); for (String evalFile : params.evalFiles) { shell.execute(String.format(":load '%s'", evalFile));
public GremlinWebConsole( Binding bindings, IO io ) { groovy = new Groovysh( bindings, io ); groovy.setResultHook( new NullResultHookClosure( groovy ) ); for ( String imps : Imports.getImports() ) { groovy.execute( "import " + imps ); } for ( String imps : Neo4jGroovyImports.getImports() ) { groovy.execute( "import " + imps ); } groovy.execute( "import com.tinkerpop.gremlin.groovy.*" ); // groovy.execute( "import .*" ); groovy.setResultHook( new GremlinResultHook( groovy, io ) ); Gremlin.load(); }
shell.execute("import " + Visibility.class.getPackage().getName() + ".*;"); shell.execute("v = new " + LazyVertexMap.class.getName() + "();"); shell.execute("e = new " + LazyEdgeMap.class.getName() + "();"); shell.execute("g = " + VertexiumScript.class.getName() + ".getGraph();"); shell.execute("auths = " + VertexiumScript.class.getName() + ".getAuthorizations();"); shell.execute("time = " + VertexiumScript.class.getName() + ".getTime();"); shell.execute("cypher = { code -> " + VertexiumScript.class.getName() + ".executeCypher(code) };"); startGroovysh(params, shell, params.evalString, params.fileNames); return 0;
public Console(final IO io, final String inputPrompt, final String resultPrompt) { io.out.println(); io.out.println(" \\,,,/"); io.out.println(" (o o)"); io.out.println("-----oOOo-(_)-oOOo-----"); final Groovysh groovy = new Groovysh(); groovy.setResultHook(new NullResultHookClosure(groovy)); for (final String imps : Imports.getImports()) { groovy.execute("import " + imps); } for (final String evs : Imports.getEvaluates()) { groovy.execute(evs); } groovy.setResultHook(new ResultHookClosure(groovy, io, resultPrompt)); groovy.setHistory(new History()); final InteractiveShellRunner runner = new InteractiveShellRunner(groovy, new PromptClosure(groovy, inputPrompt)); runner.setErrorHandler(new ErrorHookClosure(runner, io)); try { runner.setHistory(new History(new File(System.getProperty("user.home") + "/" + HISTORY_FILE))); } catch (IOException e) { io.err.println("Unable to create history file: " + HISTORY_FILE); } Gremlin.load(); FaunusGremlin.load(); try { runner.run(); } catch (Error e) { //System.err.println(e.getMessage()); } }