Termly 0.2.2

dotnet add package Termly --version 0.2.2                
NuGet\Install-Package Termly -Version 0.2.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Termly" Version="0.2.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Termly --version 0.2.2                
#r "nuget: Termly, 0.2.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Termly as a Cake Addin
#addin nuget:?package=Termly&version=0.2.2

// Install Termly as a Cake Tool
#tool nuget:?package=Termly&version=0.2.2                

Termly

Terminal colorizer for .NET console apps

NuGet NuGet

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 Windows Terminal with your favorite color scheme.

Usage

You can start adding color to the console output with InColor method extension.

private static void HandleContextLog(object sender, LoggingEventArgs e)
{
    if (e.Kind > ChannelMessageKind.Trace)
    {
        // using InColor method
        Console.Error.WriteLine($"{e.Source.InColor(ConsoleColor.Gray)}: {e.RawMessage.InColor(ConsoleColor.DarkBlue)}");
        // using WriteLineInColor method
        Console.Error.WriteLineInColor($"{e.Source:gray}: {e.RawMessage:darkBlue}");
    }
}

The extension methods Write and WriteLine are used to colorize interpolated string parameters.

Console.Out.WriteLine(ConsoleColor.DarkYellow, $"Parameters Count: {parameters.Statistics.ParametersCount}");

There are also methods WriteInColor and WriteLineInColor which allow you to colorize each interpolated string parameter independently.

Console.Out.WriteLineInColor($"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.WriteLineInColor($"{"ALERT":black|red}");
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.2 129 2/22/2024
0.2.1 211 5/18/2023
0.1.0-beta 2,502 11/26/2021