binding.setProperty("jenkins", Jenkins.getActiveInstance()); IO io = new IO(new BufferedInputStream(stdin),stdout,stderr);
private void log(final String level, Object msg, Throwable cause) { assert level != null; assert msg != null; if (io == null) { synchronized (Logger.class) { if (io == null) { io = new IO(); } } } // Allow the msg to be a Throwable, and handle it properly if no cause is given if (cause == null) { if (msg instanceof Throwable) { cause = (Throwable) msg; msg = cause.getMessage(); } } Color color = GREEN; if (WARN.equals(level) || ERROR.equals(level)) { color = RED; } io.out.println(ansi().a(INTENSITY_BOLD).fg(color).a(level).reset().a(" [").a(name).a("] ").a(msg)); if (cause != null) { cause.printStackTrace(io.out); } io.flush(); }
public Console() { this(new IO(System.in, System.out, System.err), STANDARD_INPUT_PROMPT, STANDARD_RESULT_PROMPT); }
public void start() { System.setProperty("plugins", "v3d3"); PipedInputStream in = new PipedInputStream(); replaceSystemIn(in); try { input = new PrintWriter(new PipedOutputStream(in)); } catch (IOException e) { throw new RuntimeException(e); } console = new Thread(() -> new Console(new IO(), new ArrayList<>(), true)); console.start(); }
private Groovysh createShell() { if (welcomeMessage != null) { writer.println(SEPARATOR_BAR); writer.println(welcomeMessage); writer.println(SEPARATOR_BAR); } binding.setVariable(OUT_KEY, out); final CompilerConfiguration config = new CompilerConfiguration(); final GroovyClassLoader loader = new GroovyClassLoader(this.getClass().getClassLoader(), config); final Groovysh shell = new Groovysh(loader, binding, new IO(in, out, out)); writer.flush(); return shell; }
private Groovysh createShell() { if (welcomeMessage != null) { writer.println(SEPARATOR_BAR); writer.println(welcomeMessage); writer.println(SEPARATOR_BAR); } binding.setVariable(OUT_KEY, out); final CompilerConfiguration config = new CompilerConfiguration(); final GroovyClassLoader loader = new GroovyClassLoader(this.getClass().getClassLoader(), config); final Groovysh shell = new Groovysh(loader, binding, new IO(in, out, out)); writer.flush(); return shell; }
public static void main(final String[] args) { Binding binding = new Binding(); // Configure your bindings here. Groovysh shell = new Groovysh(binding, new IO()); shell.run(args); }
io = new IO();
io = new IO();
final Groovysh groovy = new Groovysh(binding, new IO(in, out, out));
public GremlinSession( Database database ) { this.database = database; this.log = database.getLogging().getConsoleLog( getClass() ); PrintStream out = new PrintStream( new BufferedOutputStream( baos ) ); io = new IO( System.in, out, out ); Map<String, Object> bindings = new HashMap<String, Object>(); bindings.put( "g", getGremlinWrappedGraph() ); bindings.put( "out", out ); initialBindings = new ArrayList<String>( bindings.keySet() ); try { scriptEngine = new GremlinWebConsole( new Binding( bindings ), io ); } catch ( final Exception failure ) { scriptEngine = new GremlinWebConsole() { @Override public void execute( String script ) { io.out.println( "Could not start Groovy during Gremlin initialization, reason:" ); failure.printStackTrace( io.out ); } }; } }
@Override public void run(final ClassLoader classLoader, final ResourceLoader resourceLoader, final Map<String, Object> context, final @Nullable Map<String, Object> options) throws Exception { checkNotNull(classLoader); checkNotNull(resourceLoader); checkNotNull(context); log.trace("Running; class-loader: {}, resource-loader: {}, context: {}", classLoader, resourceLoader, context); GroovyClassLoader gcl = runtime.createGroovyClassLoader(classLoader, resourceLoader); Binding binding = runtime.createBinding(context); Groovysh shell = new Groovysh(gcl, binding, new IO()); if (options != null) { configureOptions(shell, options); } try { shell.run(null); } finally { gcl.clearCache(); } }
@Override public void run(final ClassLoader classLoader, final ResourceLoader resourceLoader, final Map<String, Object> context, final @Nullable Map<String, Object> options) throws Exception { checkNotNull(classLoader); checkNotNull(resourceLoader); checkNotNull(context); log.trace("Running; class-loader: {}, resource-loader: {}, context: {}", classLoader, resourceLoader, context); GroovyClassLoader gcl = runtime.createGroovyClassLoader(classLoader, resourceLoader); Binding binding = runtime.createBinding(context); Groovysh shell = new Groovysh(gcl, binding, new IO()); if (options != null) { configureOptions(shell, options); } try { shell.run(); } finally { gcl.clearCache(); } }
private void log(final String level, Object msg, Throwable cause) { assert level != null; assert msg != null; if (io == null) { io = new IO(); } // Allow the msg to be a Throwable, and handle it properly if no cause is given if (cause == null) { if (msg instanceof Throwable) { cause = (Throwable) msg; msg = cause.getMessage(); } } Color color = GREEN; if (WARN.equals(level) || ERROR.equals(level)) { color = RED; } io.out.println(ansi().a(INTENSITY_BOLD).a(color).a(level).reset().a(" [").a(name).a("] ").a(msg)); if (cause != null) { cause.printStackTrace(io.out); } try { io.flush(); } catch (IOException io) { throw new RuntimeException(io); } }
public DefaultTask(final Configuration config) { assert config != null; io = new IO(); Logger.io = io; if (config.get(VERBOSE, false)) { io.setVerbosity(IO.Verbosity.VERBOSE); } if (config.get(DEBUG, false)) { io.setVerbosity(IO.Verbosity.DEBUG); } if (config.get(QUIET, false)) { io.setVerbosity(IO.Verbosity.QUIET); } String color = config.get(COLOR, Boolean.TRUE.toString()); if (color != null) { Main.setColor(color); } String term = config.get(TERMINAL, (String)null); if (term != null) { Main.setTerminalType(term); } args = config.get(ARGS, (String)null); }
public DefaultTask(final Configuration config) { assert config != null; io = new IO(); Logger.io = io; if (config.get(VERBOSE, false)) { io.setVerbosity(IO.Verbosity.VERBOSE); } if (config.get(DEBUG, false)) { io.setVerbosity(IO.Verbosity.DEBUG); } if (config.get(QUIET, false)) { io.setVerbosity(IO.Verbosity.QUIET); } String color = config.get(COLOR, Boolean.TRUE.toString()); if (color != null) { Main.setColor(color); } String term = config.get(TERMINAL, (String)null); if (term != null) { Main.setTerminalType(term); } args = config.get(ARGS, (String)null); }
public DefaultTask(final Configuration config) { assert config != null; io = new IO(); Logger.io = io; if (config.get(VERBOSE, false)) { io.setVerbosity(IO.Verbosity.VERBOSE); } if (config.get(DEBUG, false)) { io.setVerbosity(IO.Verbosity.DEBUG); } if (config.get(QUIET, false)) { io.setVerbosity(IO.Verbosity.QUIET); } String color = config.get(COLOR, Boolean.TRUE.toString()); if (color != null) { Main.setColor(color); } String term = config.get(TERMINAL, (String)null); if (term != null) { Main.setTerminalType(term); } args = config.get(ARGS, (String)null); }
public DefaultTask(final Configuration config) { assert config != null; io = new IO(); Logger.io = io; if (config.get(VERBOSE, false)) { io.setVerbosity(IO.Verbosity.VERBOSE); } if (config.get(DEBUG, false)) { io.setVerbosity(IO.Verbosity.DEBUG); } if (config.get(QUIET, false)) { io.setVerbosity(IO.Verbosity.QUIET); } String color = config.get(COLOR, Boolean.TRUE.toString()); if (color != null) { Main.setColor(color); } String term = config.get(TERMINAL, (String)null); if (term != null) { Main.setTerminalType(term); } args = config.get(ARGS, (String)null); }
public DefaultTask(final Configuration config) { assert config != null; io = new IO(); Logger.io = io; if (config.get(VERBOSE, false)) { io.setVerbosity(IO.Verbosity.VERBOSE); } if (config.get(DEBUG, false)) { io.setVerbosity(IO.Verbosity.DEBUG); } if (config.get(QUIET, false)) { io.setVerbosity(IO.Verbosity.QUIET); } String color = config.get(COLOR, Boolean.TRUE.toString()); if (color != null) { Main.setColor(color); } String term = config.get(TERMINAL, (String)null); if (term != null) { Main.setTerminalType(term); } args = config.get(ARGS, (String)null); }
public DefaultTask(final Configuration config) { assert config != null; io = new IO(); Logger.io = io; if (config.get(VERBOSE, false)) { io.setVerbosity(IO.Verbosity.VERBOSE); } if (config.get(DEBUG, false)) { io.setVerbosity(IO.Verbosity.DEBUG); } if (config.get(QUIET, false)) { io.setVerbosity(IO.Verbosity.QUIET); } String color = config.get(COLOR, Boolean.TRUE.toString()); if (color != null) { Main.setColor(color); } String term = config.get(TERMINAL, (String)null); if (term != null) { Main.setTerminalType(term); } args = config.get(ARGS, (String)null); }