ConsoleCompanion 1.3.0

dotnet add package ConsoleCompanion --version 1.3.0
NuGet\Install-Package ConsoleCompanion -Version 1.3.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="ConsoleCompanion" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ConsoleCompanion --version 1.3.0
#r "nuget: ConsoleCompanion, 1.3.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.
// Install ConsoleCompanion as a Cake Addin
#addin nuget:?package=ConsoleCompanion&version=1.3.0

// Install ConsoleCompanion as a Cake Tool
#tool nuget:?package=ConsoleCompanion&version=1.3.0

A library with helper functions for console applications

Usage

using ConsoleCompanion

ConsoleCompanionHelper cc = new()

cc.AskForInt()

Methods

AskForInt

cc.AskForInt(questionString, errorMessageString)

cc.AskForInt(minValue, maxValue, questionString, errorMessageString)

AskForDouble

cc.AskForDouble(questionString, errorMessageString)

cc.AskForDouble(minValue, maxValue, questionString, errorMessageString)

AskForChar

cc.AskForChar(questionString)

cc.AskForChar(CharType.Letter/Digit, questionString, errorMessageString)

AskForString

cc.AskForString(questionString)

cc.AskForString(Regex, questionString, errorMessageString)

WriteError

Prints text in red

cc.WriteError(message)

WriteWarning

Prints text in yellow

cc.WriteWarning(message)

WriteSuccess

Prints text in green

cc.WriteSuccess(message)

WriteAtPosition

Writes text from given starting point

cc.WriteAtPosition(leftPostion message)

cc.WriteAtPosition(leftPostion, topPosition, message)

ClearConsoleLine

Erases text in the given line and sets the cursor back at the start of the same line

cc.ClearConsoleLine(lineNumber)

CreateMenu

Creates a menu that you can navigate with your arrow-keys, it returns the index of the chosen option

If canCancel is set to true it will return -1 when you press ESC

cc.CreateMenu(
	//  An array with strings to print as menu options
	string[] options,				
	
	//  The menu title
	string menuTitle = "Menu options, select with enter:", 

	//  Defines the color of the text that is currently active
	ConsoleColor activeChoiceColor = ConsoleColor.Green,

	//  Defines if you can go back out from the menu with ESC
	bool canCancel = false,			
	
	//  Starting column to print at
	int startCol = 8,			
	
	//  Starting row to print at
	int startRow = 15,			
	
	//  How many options per column
	int optionsPerColumn = 3,		
	
	//  Spacing between columns
	int columnSpacing = 14,			
	
	//  Should it print the menu numbers
	bool enumerate = true                                  
) 

The generic version returns a V

if canCancel is set to true it will return default(V), which is null

cc.CreateMenu<<MenuContainer<V>, V>(
	//  A list of MenuContainers to use as the menu option values
	List<MenuContainer<V> options,				
	
	//  The menu title
	string menuTitle = "Menu options, select with enter:", 

	//  Defines the color of the text that is currently active
	ConsoleColor activeChoiceColor = ConsoleColor.Green,

	//  Defines if you can go back out from the menu with ESC
	bool canCancel = false,			
	
	//  Starting column to print at
	int startCol = 8,			
	
	//  Starting row to print at
	int startRow = 15,			
	
	//  How many options per column
	int optionsPerColumn = 3,		
	
	//  Spacing between columns
	int columnSpacing = 14,			
	
	//  Should it print the menu numbers
	bool enumerate = true                                  
) 

CreateMultipleChoiceMenu

Creates a menu that you can navigate with your arrow-keys and select multiple options with the spacebar, it will return a list on the indexes of the options chosen

If canCancel is set to true it will return an empty List

cc.CreateMultipleChoiceMenu(
	//  An array with strings to print as menu options
	string[] options,				
	
	//  The menu title
	string menuTitle = "Menu options, select with enter:", 

	//  Defines the color of the text that is currently active
	ConsoleColor activeChoiceColor = ConsoleColor.Green,

	//  Defines the color of the options that have been selected
    ConsoleColor chosenValueColor = ConsoleColor.DarkGreen,

	//  Defines if you can go back out from the menu with ESC
	bool canCancel = false,			
	
	//  Starting column to print at
	int startCol = 8,			
	
	//  Starting row to print at
	int startRow = 15,			
	
	//  How many options per column
	int optionsPerColumn = 3,		
	
	//  Spacing between columns
	int columnSpacing = 14,			
	
	//  Should it print the menu numbers
	bool enumerate = true                                  
) 

The generic returns a List of V

cc.CreateMultipleChoiceMenu<<MenuContainer<V>, V>(
	//  An array with strings to print as menu options
	List<MenuContainer<V>> options,				
	
	//  The menu title
	string menuTitle = "Menu options, select with enter:", 

	//  Defines the color of the text that is currently active
	ConsoleColor activeChoiceColor = ConsoleColor.Green,

	//  Defines the color of the options that have been selected
    ConsoleColor chosenValueColor = ConsoleColor.DarkGreen,

	//  Defines if you can go back out from the menu with ESC
	bool canCancel = false,			
	
	//  Starting column to print at
	int startCol = 8,			
	
	//  Starting row to print at
	int startRow = 15,			
	
	//  How many options per column
	int optionsPerColumn = 3,		
	
	//  Spacing between columns
	int columnSpacing = 14,			
	
	//  Should it print the menu numbers
	bool enumerate = true                                  
) 
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.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
1.3.0 226 11/24/2023
1.2.3 84 11/24/2023
1.2.2 97 11/24/2023