MiJenner.ConsoleUtils 0.9.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MiJenner.ConsoleUtils --version 0.9.0
                    
NuGet\Install-Package MiJenner.ConsoleUtils -Version 0.9.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="MiJenner.ConsoleUtils" Version="0.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MiJenner.ConsoleUtils" Version="0.9.0" />
                    
Directory.Packages.props
<PackageReference Include="MiJenner.ConsoleUtils" />
                    
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 MiJenner.ConsoleUtils --version 0.9.0
                    
#r "nuget: MiJenner.ConsoleUtils, 0.9.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 MiJenner.ConsoleUtils@0.9.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=MiJenner.ConsoleUtils&version=0.9.0
                    
Install as a Cake Addin
#tool nuget:?package=MiJenner.ConsoleUtils&version=0.9.0
                    
Install as a Cake Tool

MiJenner.ConsoleUtils

ConsoleUtils offer cross-platform utilities for easy interaction with a user.

There are methods for persistent reading of values of a certain data type from the console user. Pattern is ```cs Read<datatype>()````. They prompt the user, and keep asking user for a value of a certain data type until she/he enters a correct data type. It offers methods for integers, doubles, decimals, boolean, dates, and enums.

There is a method for reading in multiple lines of text from the user StringReadMultipleLines.

There are methods for removing non-letters from strings: cs StringRemoveNonLettersENG(...) and cs StringRemoveNonLettersAll(...).

Finally there are methods for opening file explorer in current directory cs OpenExplorerFinder()

Method Signatures

Below is listed the signatures of the methods:

  • cs public static void OpenExplorerFinder()
  • cs public static void OpenExplorerFinderPath(string folderPath)
  • cs public static int ReadInt(string prompt, string errorMessage)
  • cs public static double ReadDouble(string prompt, string errorMessage)
  • cs public static decimal ReadDecimal(string prompt, string errorMessage)
  • cs public static bool ReadBoolean(string prompt, string errorMessage, string trueValue = "j", string falseValue = "n")
  • cs public static DateTime ReadDate(string prompt, string errorMessage)
  • cs public static T ReadEnum<T>(string prompt, string errorMessage) where T : struct, Enum
  • cs public static string StringRemoveNonLettersENG(string input)
  • cs public static string StringRemoveNonLettersAll(string input)
  • cs public static string StringReadMultipleLines(string prompt, string instruction = "Type 3 empty lines to end")

Examples

Below are examples on how the library can be used:

ConsoleUtils.OpenExplorerFinder();
ConsoleUtils.OpenExplorerFinderPath("."); 
var a = ConsoleUtils.ReadInt("Please provide an integer", "No, please provide an integer");
var b = ConsoleUtils.ReadDouble("Please provide a floating point number", "No, please provide a floating point number");
var c = ConsoleUtils.ReadDate("Please provide a date", "No, please provide a date");
var d = ConsoleUtils.ReadBoolean("Please provide a boolean", "No, please provide a boolean", "t", "f");
var e = ConsoleUtils.ReadEnum<MyEnum>("Please provide an enum, MyEnum", "No, please provide an enum, MyEnum");

Nuget package

There is a nuget package available for easy usage.

*

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.
  • 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.14.0 208 9/18/2023
0.12.0 155 9/18/2023
0.11.0 169 9/12/2023
0.10.0 181 9/11/2023
0.9.0 190 9/9/2023