public void flush() throws IOException { if (real != null) { real.flush(); } else { peekContext().flush(); } } public void close() throws IOException {
public void close() throws IOException { if (real != null) { try { real.close(); } finally { popContext(); } } else { InvocationContext<?> context = popContext(); context.close(); } CRaSHCommand.this.unmatched = null; } };
protected final String readLine(String msg) { return readLine(msg, true); }
if (owner instanceof CRaSHCommand) { cmd = owner; ctx = ((CRaSHCommand)cmd).peekContext(); break; } else if (owner instanceof GroovyScriptCommand) { ((CRaSHCommand)cmd).pushContext(nested); } else { ((GroovyScriptCommand)cmd).pushContext(nested); ((CRaSHCommand)cmd).popContext(); } else { ((GroovyScriptCommand)cmd).popContext();
pushContext(invocationContext); throw new org.crsh.command.SyntaxException(e.getMessage()); } catch (InvocationException e) { throw toScript(e.getCause()); } else { if (ret != null) { peekContext().getWriter().print(ret);
public CommandInvoker<?, ?> resolveInvoker(String name, Map<String, ?> options, List<?> args) { if (options.containsKey("h") || options.containsKey("help")) { throw new UnsupportedOperationException("Implement me"); } else { InvocationMatcher matcher = descriptor.invoker("main"); InvocationMatch<CRaSHCommand> match = null; try { match = matcher.match(name, options, args); } catch (org.crsh.cli.SyntaxException e) { throw new org.crsh.command.SyntaxException(e.getMessage()); } return resolveInvoker(match); } }
if (cmd instanceof CRaSHCommand) { CRaSHCommand cc = (CRaSHCommand)cmd; CommandDescriptor<?> desc = cc.getDescriptor(); if (desc.getSubordinates().size() > 1) { for (CommandDescriptor<?> m : desc.getSubordinates().values()) {
public final void open(CommandContext<Object> consumer) { // Set up current binding Binding binding = new Binding(consumer.getSession()); // Set the args on the script binding.setProperty("args", args); // setBinding(binding); // pushContext(new InvocationContextImpl<Object>(consumer)); // try { // Object res = run(); // Evaluate the closure if (res instanceof Closure) { Closure closure = (Closure)res; res = closure.call(args); } // if (res != null) { RenderPrintWriter writer = peekContext().getWriter(); if (writer.isEmpty()) { writer.print(res); } } } catch (Exception t) { throw CRaSHCommand.toScript(t); } }
public CommandInvoker<?, ?> resolveInvoker(String line) { InvocationMatcher analyzer = descriptor.invoker("main"); InvocationMatch<CRaSHCommand> match; try { match = analyzer.match(line); } catch (org.crsh.cli.SyntaxException e) { throw new org.crsh.command.SyntaxException(e.getMessage()); } return resolveInvoker(match); }
public final void execute(String s) throws ScriptException, IOException { InvocationContext<?> context = peekContext(); CommandInvoker invoker = context.resolve(s); invoker.open(context); invoker.flush(); invoker.close(); }
context = ((CRaSHCommand)owner).peekContext(); } else if (owner instanceof GroovyScriptCommand) { context = (InvocationContext)((GroovyScriptCommand)owner).peekContext();