Search in sources :

Example 1 with LineInput

use of com.teradata.jaqy.interfaces.LineInput in project jaqy by Teradata.

the class RunCommand method execute.

@Override
public void execute(String[] args, boolean silent, JaqyInterpreter interpreter) throws Exception {
    CommandLine cmdLine = getCommandLine(args);
    String encoding = cmdLine.getOptionValue('c');
    args = cmdLine.getArgs();
    if (args.length == 0) {
        interpreter.error("missing file name.");
    }
    LineInput input = null;
    try {
        input = LineInputFactory.getLineInput(interpreter.getPath(args[0]), encoding, false);
    } catch (IOException e) {
        interpreter.error("invalid file: " + args[0]);
    }
    if (!silent)
        interpreter.println("-- Running script: " + args[0]);
    interpreter.push(input);
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) IOException(java.io.IOException) LineInput(com.teradata.jaqy.interfaces.LineInput)

Example 2 with LineInput

use of com.teradata.jaqy.interfaces.LineInput in project jaqy by Teradata.

the class StackedLineInput method getInput.

private LineInput getInput() {
    synchronized (m_lock) {
        if (m_input != null)
            return m_input;
        if (m_inputs.isEmpty())
            return null;
        LineInput input = m_inputs.pop();
        m_input = input;
        return input;
    }
}
Also used : LineInput(com.teradata.jaqy.interfaces.LineInput)

Example 3 with LineInput

use of com.teradata.jaqy.interfaces.LineInput in project jaqy by Teradata.

the class StackedLineInput method pop.

private LineInput pop() {
    synchronized (m_lock) {
        if (m_input == null)
            return null;
        if (m_inputs.isEmpty()) {
            m_input = null;
            return null;
        }
        LineInput input = m_inputs.pop();
        m_input = input;
        return input;
    }
}
Also used : LineInput(com.teradata.jaqy.interfaces.LineInput)

Example 4 with LineInput

use of com.teradata.jaqy.interfaces.LineInput 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();
        }
    }
}
Also used : FilePath(com.teradata.jaqy.path.FilePath) Path(com.teradata.jaqy.interfaces.Path) FilePath(com.teradata.jaqy.path.FilePath) ReaderLineInput(com.teradata.jaqy.lineinput.ReaderLineInput) JLineConsoleLineInput(com.teradata.jaqy.lineinput.JLineConsoleLineInput) LineInput(com.teradata.jaqy.interfaces.LineInput) CommandLineInput(com.teradata.jaqy.lineinput.CommandLineInput) ReaderLineInput(com.teradata.jaqy.lineinput.ReaderLineInput)

Aggregations

LineInput (com.teradata.jaqy.interfaces.LineInput)4 Path (com.teradata.jaqy.interfaces.Path)1 CommandLineInput (com.teradata.jaqy.lineinput.CommandLineInput)1 JLineConsoleLineInput (com.teradata.jaqy.lineinput.JLineConsoleLineInput)1 ReaderLineInput (com.teradata.jaqy.lineinput.ReaderLineInput)1 FilePath (com.teradata.jaqy.path.FilePath)1 IOException (java.io.IOException)1 CommandLine (org.apache.commons.cli.CommandLine)1