Skip to content

Instantly share code, notes, and snippets.

@SteveL-MSFT
Last active September 2, 2021 02:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SteveL-MSFT/12b6cde8752e58325ce3ac6db97149e0 to your computer and use it in GitHub Desktop.
Save SteveL-MSFT/12b6cde8752e58325ce3ac6db97149e0 to your computer and use it in GitHub Desktop.
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