WriterUI 2.0.0

dotnet add package WriterUI --version 2.0.0
                    
NuGet\Install-Package WriterUI -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="WriterUI" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WriterUI" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="WriterUI" />
                    
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 WriterUI --version 2.0.0
                    
#r "nuget: WriterUI, 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 WriterUI@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=WriterUI&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=WriterUI&version=2.0.0
                    
Install as a Cake Tool

WriterUI - Console UI Helper

Welcome to WriterUI, your go-to library for simplifying console-based user interactions and message formatting.

Description

WriterUI provides a set of functional methods for interacting with the console, allowing you to display formatted messages, capture user input, and customize the console output. Written in F# to leverage functional programming patterns and pipeline operations.

Features

1. Formatted Messages

Display formatted messages with optional colors and spacing.

message None "Welcome to the writer console UI helper!"
error "Oops! Something went wrong."
warn "Warning: Proceed with caution."

2. Input Capture

Type-safe input capture with built-in error handling.

let intInput = inputTyped<int> None (Some "Please enter an integer:")
let boolInput = inputTyped<bool> None (Some "Enter 'true' or 'false':")
let strInput = input None (Some "Enter a string:")

3. Customisation

Customise colors and formatting using the WriteOptions record:

message (Some { 
    CustomColor = Some ConsoleColor.Magenta
    BackgroundColor = Some ConsoleColor.Black
    IncludeLineSpace = true 
}) "Customized message!"

let customInput = input 
    (Some { 
        CustomColor = Some ConsoleColor.DarkCyan
        BackgroundColor = None
        IncludeLineSpace = true 
    }) 
    (Some "Enter with style:")

Usage

Installation

Add the WriterUI library through NuGet Package Manager.

Basic Usage

open WriterUI

message None "Welcome to my application!"
let age = inputTyped<int> None (Some "Please enter your age:")

Why F#?

The library has been rewritten in F# to:

  • Better support functional programming patterns
  • Enable pipeline operations with consistent parameter ordering
  • Provide cleaner option handling
  • Leverage F#'s type inference and pattern matching
  • Simplify error handling

Type Safety

The library provides type-safe input handling using F#'s generic constraints:

let age = inputTyped<int> None (Some "Enter age:")  // Works
let request = inputTyped<HttpClient> None (Some "Stringify an HttpClient?") // No way!
let name = input None (Some "Enter name:")          // String input

Considerations

  • Error handling is built into inputTyped<'T> with recursive retry
  • All functions handle None cases gracefully
  • Background colors automatically reset to terminal defaults
  • Thread-safe console operations

License

MIT License. See the LICENSE file for details.

v2.0.0 Key changes:

  • Updated syntax to show F# examples
  • Removed C# examples and namespace references
  • Added explanation for F# migration
  • Simplified API examples
  • Updated configuration examples to use F# record syntax
  • Added note about background color handling
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.  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 128 2/22/2025
1.0.1 155 2/2/2024