RunScriptTool implements Tool { @Override public void run(CommandLine line, ToolRunningContext context) { Path file = context.getFileSystem().getPath(line.getOptionValue(FILE)); if (file.getFileName().toString().endsWith(".groovy")) { try { Binding binding = new Binding(); binding.setProperty("args", line.getArgs()); GroovyScripts.run(file, binding, context.getOutputStream()); } catch (Exception e) { Throwable rootCause = StackTraceUtils.sanitizeRootCause(e); rootCause.printStackTrace(context.getErrorStream()); } } else { throw new IllegalArgumentException("Script type not supported"); } }  @Override Command getCommand(); @Override void run(CommandLine line, ToolRunningContext context); static final String FILE; }
@Test public void run() throws Exception { String helloFile = "/hello.groovy"; createFile(helloFile, "print 'hello'"); assertCommand(new String[] {"run-script", "--file", helloFile}, CommandLineTools.COMMAND_OK_STATUS, "hello", ""); }