-
Notifications
You must be signed in to change notification settings - Fork 215
-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiline support #36
Comments
For which behavior ? You mean using |
Hello What I need is:
SELECT * <return>
FROM myTable <return>
WHERE myTable.id = 42; <return>
I want to reproduce the same behavior than, for example, plsql or mysql clients. |
You need to implement a custom |
Awesome! I just could do it with JLine 3.1.2. |
@pabloa could you point me to your implementation? I'm curious to see how you did it. |
@j2kun that happened in 2016 in a long time gone company. ;) |
For posterity let me include my version, happy to hear of any improvements you might see. @gnodet any chance a version of this could be included in the library, to save future fools like me the effort? :) import org.jline.reader.EOFError;
import org.jline.reader.ParsedLine;
import org.jline.reader.Parser;
import org.jline.reader.SyntaxError;
import org.jline.reader.impl.DefaultParser;
/** A jline extension for SQL-like inputs. Commands are terminated with a semicolon. */
public final class MultilineParser implements Parser {
private static final Parser DEFAULT_PARSER = new DefaultParser();
@Override
public ParsedLine parse(String line, int cursor, Parser.ParseContext context) throws SyntaxError {
if ((Parser.ParseContext.UNSPECIFIED.equals(context) || Parser.ParseContext.ACCEPT_LINE.equals(context))
&& !line.trim().endsWith(";")) {
throw new EOFError(-1, cursor, "Missing semicolon (;)");
}
return DEFAULT_PARSER.parse(line, cursor, context);
}
public MultilineParser() {}
} Then this parser is passed to the line reader as: LineReaderBuilder.builder().terminal(terminal).parser(new MultilineParser()).build(); |
* There is no support for multiline strings in interactive mode. It requires implementing our own parser for jline 3 [1] that can be done but not now. [1] - jline/jline3#36 Signed-off-by: apakhomov <apkhmv@gmail.com>
* There is no support for multiline strings in interactive mode. It requires implementing our own parser for jline 3 [1] that can be done but not now. [1] - jline/jline3#36
Hello,
I am using jline3 to write a sql client. Some users write SQL sentences using multiple lines. A SQL command could have multiple lines and it finishes with a ';' in the end.
Is it possible to tell jline3 to use ; as the end of the line in LineReaderImpl (or in the class performing that job)?
The text was updated successfully, but these errors were encountered: