Last active
September 2, 2021 02:39
-
-
Save SteveL-MSFT/12b6cde8752e58325ce3ac6db97149e0 to your computer and use it in GitHub Desktop.
Example using System.Commandline.Rendering.dll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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