This repository was archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Addded streaming results from the driver #108
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| import org.neo4j.shell.exception.AnsiFormattedException; | ||
|
|
||
| import javax.annotation.Nonnull; | ||
| import java.io.BufferedOutputStream; | ||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.PrintStream; | ||
| import java.nio.charset.StandardCharsets; | ||
|
|
@@ -23,6 +24,8 @@ public class AnsiLogger implements Logger { | |
| private final PrintStream err; | ||
| private final boolean debug; | ||
| private Format format; | ||
| private int width; | ||
| private boolean wrap = true; | ||
|
|
||
| public AnsiLogger(final boolean debug) { | ||
| this(debug, Format.VERBOSE, System.out, System.err); | ||
|
|
@@ -66,6 +69,19 @@ private static boolean isOutputInteractive() { | |
| return 1 == isatty(STDOUT_FILENO) && 1 == isatty(STDERR_FILENO); | ||
| } | ||
|
|
||
| public int getWidth() { | ||
| return width != -1 || isOutputInteractive() ? width : -1; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean getWrap() { | ||
| return wrap; | ||
| } | ||
|
|
||
| public void setWrap(boolean wrap) { | ||
| this.wrap = wrap; | ||
| } | ||
|
|
||
| @Nonnull | ||
| @Override | ||
| public PrintStream getOutputStream() { | ||
|
|
@@ -94,6 +110,11 @@ public boolean isDebugEnabled() { | |
| return debug; | ||
| } | ||
|
|
||
| @Override | ||
| public void setWidth(int width) { | ||
| this.width = width; | ||
| } | ||
|
|
||
| @Override | ||
| public void printError(@Nonnull Throwable throwable) { | ||
| printError(getFormattedMessage(throwable)); | ||
|
|
@@ -131,9 +152,9 @@ String getFormattedMessage(@Nonnull final Throwable e) { | |
| cause.getMessage() != null && cause.getMessage().contains("Missing username")) { | ||
| // Username and password was not specified | ||
| msg = msg.append(cause.getMessage()) | ||
| .append("\nPlease specify --username, and optionally --password, as argument(s)") | ||
| .append("\nor as environment variable(s), NEO4J_USERNAME, and NEO4J_PASSWORD respectively.") | ||
| .append("\nSee --help for more info."); | ||
| .append("\nPlease specify --username, and optionally --password, as argument(s)") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| .append("\nor as environment variable(s), NEO4J_USERNAME, and NEO4J_PASSWORD respectively.") | ||
| .append("\nSee --help for more info."); | ||
| } else { | ||
| if (cause.getMessage() != null) { | ||
| msg = msg.append(cause.getMessage()); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deeply disagree with this design decision. The program should output a sensible width automatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neo4j-client has a similar option,
:set width=???(a cli option, allowing width changes at runtime, rather than a command line switch). It also accepts:set width=auto, which checks the terminal window size and sets the size based on that (autois the default). Assuming Java supports finding the termwidth, perhaps a width option (with default) is a neat solution here too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well if I were designing this, I'd have a single switch:
--wrap[=[false|true|INT]]where true would be some kind of automatic width (or sensible value).