fusesource / jansi

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.
http://fusesource.github.io/jansi/
Apache License 2.0
1.12k stars 140 forks source link

Add Ansi.apply method #188

Closed romge closed 3 years ago

romge commented 3 years ago

Adds a new method "apply" to the Ansi class. This is especially useful when used with lambdas. Applying other functions to the Ansi class is now possible without breaking out of the fluent API flow. This is best shown with the following example:

Before:

Ansi ansi = Ansi.ansi().fgRed();
complexFunction(ansi);
ansi.reset();

Now:

Ansi ansi = Ansi.ansi().fgRed().apply(this::complexFunction).reset();