-
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
ColorScheme not working #1186
Comments
@sysmat Are colors showing correctly when you execute To help troubleshoot this issue, can you run again with system property The powershell problem may be related to this issue. |
|
Thank you! I see what the cause is: the Can you provide details on the terminal software name and version? |
I'm using Windows Terminal Version: 1.3.2651.0 with the different host terminal
|
By the way, can you also provide |
|
Thank you! Looks like on PowerShell, picocli cannot detect that ANSI escape codes are supported. import org.fusesource.jansi.AnsiConsole;
...
public static void main(String[] args) {
AnsiConsole.systemInstall(); // enable colors on Windows
new CommandLine(new TopLavelCommands()).execute(args);
AnsiConsole.systemUninstall(); // cleanup when done
} ...or ask your users to set one of the environment variables that picocli uses to determine if ANSI escape codes are supported. I recommend Jansi, or picocli-jansi-graalvm. It is used like this: import picocli.jansi.graalvm.AnsiConsole; // not org.fusesource.jansi.AnsiConsole
...
try (AnsiConsole ansi = AnsiConsole.windowsInstall()) { // enable colors on Windows
new CommandLine(new MyApp()).execute(args);
} // Closeable does cleanup when done |
(Git for Windows, MSYS2-based Windows Terminal shells, etc.)
@sysmat I finally got around to putting in a fix for MSYS2 (auto-enable ANSI when env var Can you confirm that this solves the issue in the MSYS2-based Windows Terminal shell? To verify, check out picocli master locally, and build it with
You can then try this in a project that uses the |
@sysmat Can you think of a way to detect from the Java process whether it was launched from PowerShell or from some other shell like CMD? That would help further improve picocli's ANSI heuristics. If we cannot improve the heuristics, then the best thing that picocli-based applications can do is to always use Jansi (at least when running on Windows). Thoughts? |
I have started the release for picocli 4.5.2, which contains the fix for MSYS2. I don't have a solution for Powershell... This may be a Powershell issue (looking at #849). |
@sysmat Can you confirm that colors work correclty in MSYS2 (gitbash) with picocli 4.5.2? |
|
Oh no, that gitbash output looks bad... Also, can you print the output of gitbash when you run with |
I cannot reproduce this. How do I set up a MSYS2-based Windows Terminal shell? |
{
"guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c200}",
"hidden": false,
"name": "GitBash",
"commandline": "\"%PROGRAMFILES%\\git\\bin\\bash.exe\" --login -i -l",
"icon": "%PROGRAMFILES%\\git\\mingw64\\share\\git\\git-for-windows.ico"
}
|
Gitbash in TerminalI was able to reproduce some strangeness when running By the way, the value of the PowershellAbout Powershell: is your application using Jansi? Using Jansi is the most reliable way to get colors in Powershell. I gave more details in an earlier comment. Without that, you can try setting one of the environment variables that picocli checks: # set environment variable
$Env:CLICOLOR=1
# now run a command that shows colored output
java -cp "picocli-4.5.2.jar;picocli-4.5.2-tests.jar" picocli.Demo |
|
ok, I propose we put Powershell aside. I believe this (PS) is working as expected. |
AnsiConsole.systemInstall();
CommandLine commands = new CommandLine(new TopLavelCommands()).setExecutionExceptionHandler(errorHandler);
System.exit(commands.execute(args));
AnsiConsole.systemUninstall(); // cleanup when done |
Do you mean that with Jansi, you also see correct output in gitbash in Windows Terminal? |
Yes, it solved the problem and also no strange output like
|
That is good. Still weird that plain gitbash works fine for me but gitbash in Terminal gives strange layout problems. Does plain gitbash (without Terminal) work correctly for you without Jansi? (Trying to isolate whether the problem is with Terminal...) |
not using jansi
|
Looks to be a Terminal issue... |
Yes, I think so, thx again :) |
Great! |
picocli: 4.5.1
When exception is in Callable then from cli I should expect massage to be color red, but is not(powershell, gitbash)
My code:
The text was updated successfully, but these errors were encountered: