Skip to content
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

Update logic for detecting if the output stream is connected to a terminal #2084

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use reflection for the Console class
  • Loading branch information
cushon committed Aug 11, 2023
commit 1fca206e96b8c8c27aa6ebda6ab289d3e1fb1584
2 changes: 1 addition & 1 deletion src/main/java/picocli/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -17846,7 +17846,7 @@ static boolean calcTTY() {
return false;
}
try {
Method isTerminal = Console.class.getDeclaredMethod("isTerminal");
Method isTerminal = Class.forName("java.io.Console").getDeclaredMethod("isTerminal");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but the Console class was introduced in Java 6, and picocli supports Java 5, so can you change this to find the Console class via reflection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done

return (boolean) isTerminal.invoke(console);
} catch (NoSuchMethodException e) {
return true;
Expand Down
Loading