itbXLib 2.0.0

dotnet add package itbXLib --version 2.0.0
                    
NuGet\Install-Package itbXLib -Version 2.0.0
                    
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="itbXLib" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="itbXLib" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="itbXLib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add itbXLib --version 2.0.0
                    
#r "nuget: itbXLib, 2.0.0"
                    
#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.
#:package itbXLib@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=itbXLib&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=itbXLib&version=2.0.0
                    
Install as a Cake Tool

itbXLib

License .NET NuGet

A .NET helper library for console applications used in educational projects at ITecBCN.

Features 🌟

  • Terminal color helpers with RGB and HEX to ANSI conversion
  • Text styles (bold, italic/cursive, underline, and combined styles)
  • Emoji helpers for UTF-8 output and Unicode code point conversion
  • Runtime terminal capability detection with safe fallback to plain output
  • Generic validated input helper for reusable parsing and validation

Installation 📥

.NET CLI

dotnet add package itbXLib

Package Manager Console

Install-Package itbXLib

PackageReference

<PackageReference Include="itbXLib" Version="*" />

Usage 💠

All public utilities are under:

using itbXLib.TerminalUtils;

Colors

string red = Colors.RgbToAnsi("#FF0000");
Console.WriteLine($"{red}Error message{Colors.Reset}");

string custom = Colors.RgbToAnsi(30, 144, 255);
Console.WriteLine($"{custom}Info message{Colors.Reset}");

Styled text and emoji

Styles.EnableEmojiSupport();

Console.WriteLine(Styles.Bold("Bold text"));
Console.WriteLine(Styles.Italic("Italic text"));
Console.WriteLine(Styles.Underline("Underlined text"));
Console.WriteLine(Styles.BoldItalicUnderline("Strong emphasis"));

string rocket = Styles.FromCodePoint(0x1F680);
Console.WriteLine(Styles.WithEmoji(rocket, "Launch ready"));

ConsoleHelper output

ConsoleHelper.ColorWriteLine("Success", ConsoleColor.Green);
ConsoleHelper.ColorWriteLine("HEX message", "#22C55E");
ConsoleHelper.HeaderSeparator("My App");

Generic input validation

int age = GenericInputs<int>.Read(
    "Enter age: ",
    "Please enter a valid non-negative integer.",
    input =>
    {
        bool ok = int.TryParse(input, out int value) && value >= 0;
        return (ok, value);
    },
    ConsoleColor.Cyan
);

Terminal compatibility behavior

TerminalCapabilities is used internally by color/style helpers:

  • It auto-detects ANSI/styling support the first time styling is used
  • If unsupported, it prints a one-time warning to Console.Error
  • Styling is disabled for that runtime and output falls back to plain text
  • You can override detection manually with TerminalCapabilities.ForceSet(bool)

Example:

TerminalCapabilities.Detect();
if (!TerminalCapabilities.StylingEnabled)
{
    Console.WriteLine("Running in plain output mode.");
}

API reference (current)

  • itbXLib.TerminalUtils.Colors
    • RgbToAnsi(int r, int g, int b)
    • RgbToAnsi(string hex)
    • Reset
  • itbXLib.TerminalUtils.Styles
    • Bold(string)
    • Italic(string)
    • Underline(string)
    • BoldItalicUnderline(string)
    • EnableEmojiSupport()
    • FromCodePoint(int)
    • WithEmoji(string emoji, string label)
  • itbXLib.TerminalUtils.ConsoleHelper
    • ColorWrite(...), ColorWriteLine(...), HeaderSeparator(string)
  • itbXLib.TerminalUtils.GenericInputs<T>
    • Read(string message, string errorMessage, Func<string, (bool isValid, T value)> validator, ConsoleColor? color = null)
  • itbXLib.TerminalUtils.TerminalCapabilities
    • StylingEnabled
    • Detect()
    • ForceSet(bool)

Notes on deprecated APIs

Deprecated members are intentionally omitted from this README. For new code, use GenericInputs<T> for input workflows and the itbXLib.TerminalUtils namespace for all terminal helpers.

Building from source

git clone https://github.com/x341dev/itbXLib.git
cd itbXLib
dotnet build

Contributing

Contributions are widely appreciated! If you want to help out, please follow these steps:

  1. Fork the repository
  2. Create a branch (git checkout -b feature/my-change)
  3. Commit using conventional commits
  4. Push and open a pull request

Changelog

See CHANGELOG.md for release history.


Made with ❤️ from Barcelona. x341dev - GitHub

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0 87 5/13/2026
1.5.1 97 5/11/2026
1.4.1 99 4/13/2026
1.4.0 94 4/10/2026
1.3.6 104 4/7/2026
1.3.1 103 4/6/2026
1.3.0 102 4/6/2026
1.2.0 141 3/23/2026
1.1.0 119 3/2/2026
1.0.0 135 2/24/2026
0.2.1 178 2/9/2026
0.2.0 174 2/5/2026
0.1.2 181 1/29/2026
0.1.1 177 1/29/2026
0.1.0 179 1/29/2026