ConsoleMenu 0.1.1

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

// Install ConsoleMenu as a Cake Tool
#tool nuget:?package=ConsoleMenu&version=0.1.1

ConsoleMenu NuGet Badge

Provide an easy means of providing simple console applications with menu options.

Features

The following features are currently implemented in ConsoleMenu:

  • Single Character Selectable Menus
    • Items are selected as simply as pressing a single character on the keyboard.
  • Typed Menus
    • Given a list of objects, the item chosen will be returned to you.
  • Create Automatically Numbered Menus
    • It is easy to create a menu that accepts the input from 1-9.
  • Automatic Overflow
    • If using the automated number menu, if the list contains more than 9 items, the menu will automatically be paginated.

Future Features

  • Make Menus Cancellable
    • At current, there is no way to go back from a menu; you must make a valid choice to revert control back to the calling code.
  • Tidy up API
    • Some internal changes including the introduction of cleaner factory methods.

Examples

The easiest method of creating a menu in ConsoleMenu is to use the TypedMenu class. This class takes a list of objects that the menu will be created for, the instructional text to be displayed and a lambda that defines how to retrieve the text to display for each menu item.

To create one, simply create a new object:

var choices = new List<SimpleClass>
{
    new SimpleClass{Name = "One"},
    new SimpleClass{Name = "Two"},
    new SimpleClass{Name = "Three"},
    new SimpleClass{Name = "Four"},
};

var menu = new TypedMenu<SimpleClass>(choices, "Choose a number", x => x.Name);

The menu can then be displayed using the Display() method:

SimpleClass pickedObject = menu.Display();

An alternative method would be to create MenuItem instances manually and to add them to a new instance of the Menu class directly.

Screenshots

Here we have a very simple menu that is linked against the keys 1-4. Hitting one of these values will return the given choice.
Simple Menu

This menu has a default value set, hitting enter will return you the value at the index notated in the brackets.
Menu With Default

This menu has more items than can fit in the standard 1-9 numbered menu therefore an extra item has been added that will take you to the next page.
Menu With Overflow

Changelog

The changelog can be viewed here.

Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has 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.1.1 9,892 12/3/2015
0.1.0 4,937 8/17/2014

0.1.1 - Downgraded to .NET 4.0 for greater compatibility.