Termly 0.2.4
dotnet add package Termly --version 0.2.4
NuGet\Install-Package Termly -Version 0.2.4
<PackageReference Include="Termly" Version="0.2.4" />
paket add Termly --version 0.2.4
#r "nuget: Termly, 0.2.4"
// Install Termly as a Cake Addin #addin nuget:?package=Termly&version=0.2.4 // Install Termly as a Cake Tool #tool nuget:?package=Termly&version=0.2.4
Termly
Terminal colorizer for .NET console apps
Termly provides an easy to use set of extension methods to display colorized text in the terminal. It doesn't support arbitrary colors, instead it reuses the same old ConsoleColor constants. The idea here is that you don't need to come up with your own unique color pallete to display textual data, you just continue using the colors the user already chose for their terminal. The colorization is achieved with the use of a small subset of ANSI escape codes.
Apps with Termly look great in any terminal, using the user's favorite color scheme.
Usage
You can start adding color to the console output with Print
, PrintLine
, and InColor
extension methods.
private static void HandleContextLog(object sender, LoggingEventArgs e)
{
if (e.Kind > ChannelMessageKind.Trace)
{
// using PrintLine method
Console.Error.PrintLine($"{e.Source:gray}: {e.RawMessage:darkBlue}");
// using InColor method
Console.Error.WriteLine($"{e.Source.InColor(ConsoleColor.Gray)}: {e.RawMessage.InColor(ConsoleColor.DarkBlue)}");
}
}
The overloaded extension methods Print
and PrintLine
are used to colorize interpolated string parameters with the same or different colors.
Console.Out.PrintLine(ConsoleColor.DarkYellow, $"Parameters Count: {parameters.Statistics.ParametersCount}");
Console.Out.PrintLine($"Count: {count:blue} Total: {total:white|green}");
Background colors are supported too.
Console.Error.WriteLine("ALERT".InColor(foreground: ConsoleColor.Black, background: ConsoleColor.Red));
Console.Error.PrintLine($"{"ALERT":black|red}");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.2.4 | 46 | 1/3/2025 |
0.2.3 | 91 | 12/9/2024 |
0.2.2 | 144 | 2/22/2024 |
0.2.1 | 219 | 5/18/2023 |
0.1.0-beta | 2,509 | 11/26/2021 |