Skip to content

Instantly share code, notes, and snippets.

@SteveL-MSFT
Last active Sep 2, 2021
Embed
What would you like to do?
Example using System.Commandline.Rendering.dll
using namespace System.CommandLine.Rendering
add-type -AssemblyName ./System.CommandLine.Rendering.dll
$cs = [ContainerSpan]::new(
[StyleSpan]::UnderlinedOn(),
[ForegroundColorSpan]::Green(),
[BackgroundColorSpan]::Yellow(),
[ContentSpan]::new("hello"),
[StyleSpan]::UnderlinedOff()
)
$cs += [ForegroundColorSpan]::Rgb(225, 110, 132)
$cs += [BackgroundColorSpan]::Reset()
$cs += [ContentSpan]::new(" there")
$sw = [System.IO.StringWriter]::new()
$cs.WriteTo($sw, [OutputMode]::Ansi)
$sw.ToString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment