Skip to content

ColorScheme not working #1186

@sysmat

Description

@sysmat

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:

static IExecutionExceptionHandler errorHandler = (Exception ex, CommandLine cmdL, ParseResult pr) -> {
        cmdL.getErr().println(cmdL.getColorScheme().errorText(ex.getMessage())); 
        return cmdL.getCommandSpec().exitCodeOnExecutionException();
};

public static void main( String[] args ) {
       ColorScheme colorScheme = createColorScheme();
       CommandLine commands = new CommandLine(new TopLavelCommands()).setColorScheme(colorScheme).setExecutionExceptionHandler(errorHandler);
        System.exit(commands ).execute(args);
}

private static ColorScheme createColorScheme() {
        return new ColorScheme.Builder()
                .commands(CommandLine.Help.Ansi.Style.bold, CommandLine.Help.Ansi.Style.underline) // combine multiple styles
                .options(CommandLine.Help.Ansi.Style.fg_yellow) // yellow foreground color
                .parameters(CommandLine.Help.Ansi.Style.fg_yellow)
                .optionParams(CommandLine.Help.Ansi.Style.italic)
                .errors(CommandLine.Help.Ansi.Style.fg_red, CommandLine.Help.Ansi.Style.bold)
                .stackTraces(CommandLine.Help.Ansi.Style.italic)
                .build();
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions