use of com.teradata.jaqy.lineinput.ReaderLineInput in project jaqy by Teradata.
the class JaqyInterpreter method executeCommand.
private void executeCommand(ParseCommand cmd, boolean interactive) {
if (!cmd.silent) {
incCommandCount();
}
if (cmd.alias != null) {
if (cmd.args == null) {
error("error parsing argument.");
}
String alias = AliasManager.replaceArgs(cmd.alias, cmd.args);
try {
push(new ReaderLineInput(new StringReader(alias), getDirectory(), false));
// interpret (false);
} catch (Throwable t) {
m_display.error(this, t);
}
} else {
JaqyCommand call = cmd.call;
if (call == null) {
++m_errorCount;
m_display.error(this, "unknown command: " + cmd.cmd);
return;
}
try {
call.execute(cmd.args, cmd.silent, this);
} catch (Throwable t) {
++m_errorCount;
m_display.error(this, t);
}
}
}
use of com.teradata.jaqy.lineinput.ReaderLineInput in project jaqy by Teradata.
the class IfCommand method parse.
@Override
public void parse(String action, Object value, boolean silent, Globals globals, JaqyInterpreter interpreter) throws IOException {
globals.log(Level.INFO, "if condition = " + value);
Display display = interpreter.getDisplay();
if (value != null && (Boolean) value) {
globals.log(Level.INFO, "running if statement");
globals.log(Level.INFO, action);
globals.log(Level.INFO, "end if statement");
interpreter.interpret(new ReaderLineInput(new StringReader(action), interpreter.getDirectory(), false), false);
if (!silent) {
display.echo(interpreter, ".end " + getName(), false);
}
} else {
if (!silent) {
String[] lines = action.split("\n");
for (String line : lines) {
display.echo(interpreter, "-- skip: " + line, false);
}
display.echo(interpreter, ".end " + getName(), false);
}
}
}
use of com.teradata.jaqy.lineinput.ReaderLineInput in project jaqy by Teradata.
the class Main method loadInit.
private static void loadInit(Globals globals, JaqyInterpreter interpreter, Display display, Path initFile) {
LineInput lineInput;
try {
Reader reader = new InputStreamReader(Main.class.getResourceAsStream(INTERNAL_INIT_RC), "UTF-8");
Path startDir = new FilePath(new File(System.getProperty("user.dir")));
lineInput = new ReaderLineInput(reader, startDir, false);
interpreter.push(lineInput);
interpreter.interpret(false);
} catch (Exception ex) {
ex.printStackTrace();
}
if (initFile != null && initFile.exists()) {
// check if ~/.jqrc exists
try {
lineInput = LineInputFactory.getLineInput(initFile, null, false);
interpreter.push(lineInput);
interpreter.interpret(false);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Aggregations