Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 1.6 KB

Readme.md

File metadata and controls

42 lines (28 loc) · 1.6 KB

Colored Printf

color drops Logo

Github Actions Status Nuget Package

This library provide a replacement to F# printf function with color support.

The syntax to set the color inside the string is $foreground;background[text] where both foreground and background are optional.

The supported colors are the one from the System.ConsoleColor enum.

Examples

// Change the color of part of a string
colorprintfn "$red[Hello] $white;red[world]."

// Use sprintf syntax
colorprintfn "Hello $green[%s]: %s" "user" "Welcome to color!"
colorprintfn "$white[Progress]: $yellow[%.2f%%] (Eta $yellow[%i] minutes)" 42.33 5

// Use interpolated strings
let life = "La vie"
let is_ = "est"
colorprintfn $"""$white;blue[%s{life} ]$black;white[{is_} ]$white;red[{"belle"}]"""

// Specify the colors from variables
let logColor = ConsoleColor.Yellow
colorprintfn "result: $%A[Hello world]" logColor
colorprintfn $"result: ${logColor}[Hello world]"

Displays :

Demo

Thanks