Extension methods to color strings like in npm.colors for JS (original) (raw)

Colors module extends string prototype with color properties which generate escape sequences, which creates conscise API for colored console output.

Something like this can be done with CsConsoleFormat. A dirty hacky version can be found in my answer Using colors in console, how to store in a simplified notation, but it doesn't support background colors. Supporting both foreground and background colors would require extension methods for both strings and spans.

Looks like it's a very common use case, so implement this API properly.