-
Notifications
You must be signed in to change notification settings - Fork 418
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
Auto detect Jansi #483
Comments
Makes a lot of sense. I like this idea a lot. What is a good way to detect that Jansi is installed? (I'm not sure that it is enough just to check that the Jansi jar is on the classpath...) |
It seems that you just need to compare AnsiConsole.out and System.out such as: Here is a quick example code: static boolean isJansiEnabled() {
try {
Class<?> ansiConsole = Class.forName("org.fusesource.jansi.AnsiConsole");
Field out = ansiConsole.getField("out");
return out.get(null) == System.out;
} catch (Exception ex) {
return false;
}
}
public static void main(String[] args) {
System.out.println(isJansiEnabled());
AnsiConsole.systemInstall();
System.out.println(isJansiEnabled());
AnsiConsole.systemUninstall();
System.out.println(isJansiEnabled());
} |
Perfect! Do you feel like providing a PR for this? |
#486 has been merged. Thanks for the contribution! |
It would be usefull to make
Ansi.AUTO
detect if Jansi is available and enabled at runtime.Thus, we wouldn't have to specify it manually.
For example:
instead of
The text was updated successfully, but these errors were encountered: