return 1;
}
invoke = true;
}
ScriptContext ctx = new SimpleScriptContext();
// Put the following objects into the context so that they
// are available to the scripts
// TODO: What else should go in here?
Bindings b = engine.getBindings(ScriptContext.ENGINE_SCOPE);
b.put("connection", shellState.getConnector());
List<Object> argValues = new ArrayList<Object>();
if (cl.hasOption(args.getOpt())) {
String[] argList = cl.getOptionValue(args.getOpt()).split(",");
for (String arg : argList) {
String[] parts = arg.split("=");
if (parts.length == 0) {
continue;
} else if (parts.length == 1) {
b.put(parts[0], null);
argValues.add(null);
} else if (parts.length == 2) {
b.put(parts[0], parts[1]);
argValues.add(parts[1]);
}
}
}
ctx.setBindings(b, ScriptContext.ENGINE_SCOPE);
Object[] argArray = argValues.toArray(new Object[argValues.size()]);
Writer writer = null;
if (cl.hasOption(out.getOpt())) {
File f = new File(cl.getOptionValue(out.getOpt()));
writer = new FileWriter(f);
ctx.setWriter(writer);
}
if (cl.hasOption(file.getOpt())) {
File f = new File(cl.getOptionValue(file.getOpt()));
if (!f.exists()) {