InterpolatedColorConsole 1.0.3
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.7.2
This package targets .NET Framework 4.7.2. The package is compatible with this framework or higher.
dotnet add package InterpolatedColorConsole --version 1.0.3
NuGet\Install-Package InterpolatedColorConsole -Version 1.0.3
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="InterpolatedColorConsole" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add InterpolatedColorConsole --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: InterpolatedColorConsole, 1.0.3"
#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 InterpolatedColorConsole as a Cake Addin #addin nuget:?package=InterpolatedColorConsole&version=1.0.3 // Install InterpolatedColorConsole as a Cake Tool #tool nuget:?package=InterpolatedColorConsole&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Interpolated Color Console
Yes, it's yet another Colored Console. But where colors can just be interpolated within strings, making it easier to use multiple colors.
Examples
ColoredConsole.SetColor(ConsoleColor.Blue).WriteLine(@"
_____ _ _ _ _ _____ _
|_ _| | | | | | | | | / ____| | |
| | _ __ | |_ ___ _ __ _ __ ___ | | __ _| |_ ___ __| | | | ___ | | ___ _ __
| | | '_ \| __/ _ \ '__| '_ \ / _ \| |/ _` | __/ _ \/ _` | | | / _ \| |/ _ \| '__|
_| |_| | | | || __/ | | |_) | (_) | | (_| | || __/ (_| | | |___| (_) | | (_) | |
|_____|_| |_|\__\___|_| | .__/ \___/|_|\__,_|\__\___|\__,_| \_____\___/|_|\___/|_|
| |
|_|
");
using (ColoredConsole.WithColor(ConsoleColor.Cyan))
{
ColoredConsole.WriteLine($"The default color was changed by the context");
Console.WriteLine("It doesn't matter if I write with ColoredConsole or regular Console");
ColoredConsole.WriteLine($"Even if we {ConsoleColor.Red}change the color inline and forget to restore it back...");
}
ColoredConsole.WriteLine($"...when contexts are disposed the previous colors are restored.").WriteLine();
ColoredConsole.SetColor(ConsoleColor.Green)
.Write("One cool thing about ").Write(ConsoleColor.Yellow, "ColoredConsole ").WriteLine("is that it allows us to use chained-methods (Fluent API).")
.Write("One way for ").Write(ConsoleColor.Yellow, "setting colors ").WriteLine("is using the Write() overloads that specify colors.")
.Write("Another way is using ").SetColor(ConsoleColor.Blue).Write("SetColor() ").RestorePreviousColor()
.SetBackgroundColor(ConsoleColor.Red).WriteLine("or SetBackgroundColor()").RestorePreviousBackgroundColor()
.WriteLine($"It's also possible to use {ConsoleColor.Red}string interpolation{ConsoleColor.Green} to change foreground or {ConsoleColor.Red:bg}background colors")
.WriteLine($"and there are symbols for {Symbols.PREVIOUS_BACKGROUND_COLOR}restoring previous colors ")
.Write("or we can also use ")
.Write(ConsoleColor.Yellow, "ResetColor()").ResetColor().Write(" which brings everything back to normal.");
ColoredConsole.WriteLine().WriteLine();
ColoredConsole.WriteLine(ConsoleColor.Green, $"Did you like it? Please give me a {ConsoleColor.Yellow}star{Symbols.PREVIOUS_COLOR} at {ConsoleColor.Blue}https://github.com/Drizin/InterpolatedColorConsole{Symbols.PREVIOUS_COLOR}");
ColoredConsole.ReadLine();
License
MIT License
See full documentation here
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.7.2
- Microsoft.CSharp (>= 4.7.0)
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on InterpolatedColorConsole:
Package | Downloads |
---|---|
CodegenCS.Runtime
Class Library and Toolkit for Code Generation using plain C# |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on InterpolatedColorConsole:
Repository | Stars |
---|---|
Drizin/CodegenCS
C# Toolkit for Code Generation (T4 alternative!)
|